]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-log.c
Use xmemdupz() in many places.
[git.git] / builtin-log.c
index 60819d15c52dc8cb13ac08ba23986e4be56279a4..e8b982db7cf7c98bff9d64affcb573b3d9676cb1 100644 (file)
@@ -441,8 +441,6 @@ static const char *clean_message_id(const char *msg_id)
 {
        char ch;
        const char *a, *z, *m;
-       char *n;
-       size_t len;
 
        m = msg_id;
        while ((ch = *m) && (isspace(ch) || (ch == '<')))
@@ -458,11 +456,7 @@ static const char *clean_message_id(const char *msg_id)
                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)
@@ -541,9 +535,7 @@ 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;