X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-shortlog.c;h=3fe754677d3f7ab11419a04dd828c70b5958ed87;hb=8371d8fd094548c1d02b8583fdbff8204a725ffc;hp=8d3f742d432c966e5afe03e8d0628eb92a73920c;hpb=1b2782a5e2f88bf5e6e2cbb58e54fea015e21af5;p=git.git diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 8d3f742d4..3fe754677 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -39,10 +39,7 @@ static void insert_author_oneline(struct path_list *list, while (authorlen > 0 && isspace(author[authorlen - 1])) authorlen--; - buffer = xmalloc(authorlen + 1); - memcpy(buffer, author, authorlen); - buffer[authorlen] = '\0'; - + buffer = xmemdupz(author, authorlen); item = path_list_insert(buffer, list); if (item->util == NULL) item->util = xcalloc(1, sizeof(struct path_list)); @@ -66,13 +63,9 @@ static void insert_author_oneline(struct path_list *list, oneline++; onelinelen--; } - while (onelinelen > 0 && isspace(oneline[onelinelen - 1])) onelinelen--; - - buffer = xmalloc(onelinelen + 1); - memcpy(buffer, oneline, onelinelen); - buffer[onelinelen] = '\0'; + buffer = xmemdupz(oneline, onelinelen); if (dot3) { int dot3len = strlen(dot3); @@ -331,4 +324,3 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) return 0; } -