{"thread":{"id":"16857","subject":"[PATCH] builtin-shortlog.c: do not unnecessarily strdup before insertion in list","startedAt":"2008-12-24T16:34:44Z","lastAt":"2008-12-24T16:34:44Z","messageCount":1,"participants":["Adeodato Simó"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"98651","messageId":"1230136484-12445-1-git-send-email-dato@net.com.org.es","threadId":"16857","inReplyTo":null,"subject":"[PATCH] builtin-shortlog.c: do not unnecessarily strdup before insertion in list","fromName":"Adeodato Simó","fromEmail":"dato@net.com.org.es","sentAt":"2008-12-24T16:34:44Z","receivedAt":"2008-12-24T16:34:44Z","isPatch":true,"sender":{"key":"dato@net.com.org.es","avatar":"https://gravatar.com/avatar/952ec7d5d5663eb8baf631b5c37f9c58480a881920dd5f8a2d3a71f969b72b53?d=mp&s=160"},"body":"The log->list always has \"strdup_strings\" activated, hence strdup'ing\nnamebuf was unnecessary. This change also removes a latent memory leak\nin the old code.\n\nSigned-off-by: Adeodato Simó <dato@net.com.org.es>\n---\n builtin-shortlog.c |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex 4c5d761..90e76ae 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -67,12 +67,9 @@ static void insert_one_record(struct shortlog *log,\n \t\tsnprintf(namebuf + len, room, \" %.*s\", maillen, boemail);\n \t}\n \n-\tbuffer = xstrdup(namebuf);\n-\titem = string_list_insert(buffer, &log->list);\n+\titem = string_list_insert(namebuf, &log->list);\n \tif (item->util == NULL)\n \t\titem->util = xcalloc(1, sizeof(struct string_list));\n-\telse\n-\t\tfree(buffer);\n \n \t/* Skip any leading whitespace, including any blank lines. */\n \twhile (*oneline && isspace(*oneline))\n-- \n1.6.0.4\n"}]}