From: Junio C Hamano Date: Wed, 11 Sep 2013 22:00:43 +0000 (-0700) Subject: Merge branch 'sb/mailmap-freeing-NULL-is-ok' X-Git-Tag: v1.8.5-rc0~151 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e5229b6a61fefcacd63d11afd49f0cdafaa60801?ds=inline;hp=-c Merge branch 'sb/mailmap-freeing-NULL-is-ok' * sb/mailmap-freeing-NULL-is-ok: mailmap: remove redundant check for freeing memory --- e5229b6a61fefcacd63d11afd49f0cdafaa60801 diff --combined mailmap.c index 3061434321,7d5caa65f3..a7969c4c2e --- a/mailmap.c +++ b/mailmap.c @@@ -153,8 -153,7 +153,7 @@@ static void read_mailmap_line(struct st if (!strncmp(buffer, abbrev, abblen)) { char *cp; - if (repo_abbrev) - free(*repo_abbrev); + free(*repo_abbrev); *repo_abbrev = xmalloc(len); for (cp = buffer + abblen; isspace(*cp); cp++) @@@ -193,17 -192,20 +192,17 @@@ static int read_mailmap_file(struct str return 0; } -static void read_mailmap_buf(struct string_list *map, - const char *buf, unsigned long len, - char **repo_abbrev) +static void read_mailmap_string(struct string_list *map, char *buf, + char **repo_abbrev) { - while (len) { - const char *end = strchrnul(buf, '\n'); - unsigned long linelen = end - buf + 1; - char *line = xmemdupz(buf, linelen); + while (*buf) { + char *end = strchrnul(buf, '\n'); - read_mailmap_line(map, line, repo_abbrev); + if (*end) + *end++ = '\0'; - free(line); - buf += linelen; - len -= linelen; + read_mailmap_line(map, buf, repo_abbrev); + buf = end; } } @@@ -227,7 -229,7 +226,7 @@@ static int read_mailmap_blob(struct str if (type != OBJ_BLOB) return error("mailmap is not a blob: %s", name); - read_mailmap_buf(map, buf, size, repo_abbrev); + read_mailmap_string(map, buf, repo_abbrev); free(buf); return 0;