{
char ch;
const char *a, *z, *m;
- char *n;
- size_t len;
m = msg_id;
while ((ch = *m) && (isspace(ch) || (ch == '<')))
die("insane in-reply-to: %s", msg_id);
if (++z == m)
return a;
- len = z - a;
- n = xmalloc(len + 1);
- memcpy(n, a, len);
- n[len] = 0;
- return n;
+ return xmemdupz(a, z - a);
}
int cmd_format_patch(int argc, const char **argv, const char *prefix)
endpos = strchr(committer, '>');
if (!endpos)
die("bogos committer info %s\n", committer);
- add_signoff = xmalloc(endpos - committer + 2);
- memcpy(add_signoff, committer, endpos - committer + 1);
- add_signoff[endpos - committer + 1] = 0;
+ add_signoff = xmemdupz(committer, endpos - committer + 1);
}
else if (!strcmp(argv[i], "--attach")) {
rev.mime_boundary = git_version_string;
sign = '-';
if (verbose) {
- char *buf = NULL;
- unsigned long buflen = 0;
- pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
- &buf, &buflen, 0, NULL, NULL, 0);
+ struct strbuf buf;
+ strbuf_init(&buf, 0);
+ pretty_print_commit(CMIT_FMT_ONELINE, commit,
+ &buf, 0, NULL, NULL, 0);
printf("%c %s %s\n", sign,
- sha1_to_hex(commit->object.sha1), buf);
- free(buf);
+ sha1_to_hex(commit->object.sha1), buf.buf);
+ strbuf_release(&buf);
}
else {
printf("%c %s\n", sign,