Merge branch 'sb/mailmap-freeing-NULL-is-ok'
authorJunio C Hamano <gitster@pobox.com>
Wed, 11 Sep 2013 22:00:43 +0000 (15:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Sep 2013 22:00:43 +0000 (15:00 -0700)
* sb/mailmap-freeing-NULL-is-ok:
mailmap: remove redundant check for freeing memory

1  2 
mailmap.c
diff --combined mailmap.c
index 30614343213442806c5fbc28e904639d35c670cf,7d5caa65f3810aa62792571663dd12072e082ab9..a7969c4c2e45df4f139c0bc85520f3bbc34da619
+++ 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;