From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Mon, 12 Oct 2015 10:11:03 +0100 Subject: [PATCH 2/2] ui-stats: do not duplicate string In-Reply-To: <1444640375-13895-2-git-send-email-list@eworm.de> References: <1444640375-13895-1-git-send-email-list@eworm.de> <1444640375-13895-2-git-send-email-list@eworm.de> Message-ID: <20151012091103.GB19802@serenity.lan> On Mon, Oct 12, 2015 at 10:59:35AM +0200, Christian Hesse wrote: > From: Christian Hesse > > string_list_insert() expects (const char*), so no need to duplicate and > free the string. > > Signed-off-by: Christian Hesse > --- > ui-stats.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) This has the same problem as the previous patch. > diff --git a/ui-stats.c b/ui-stats.c > index 02335e7..26473de 100644 > --- a/ui-stats.c > +++ b/ui-stats.c > @@ -171,24 +171,19 @@ static void add_commit(struct string_list *authors, struct commit *commit, > struct string_list_item *author, *item; > struct authorstat *authorstat; > struct string_list *items; > - char *tmp; > struct tm *date; > time_t t; > > info = cgit_parse_commit(commit); > - tmp = xstrdup(info->author); > - author = string_list_insert(authors, tmp); > + author = string_list_insert(authors, info->author); > if (!author->util) > author->util = xcalloc(1, sizeof(struct authorstat)); > - free(tmp); > authorstat = author->util; > items = &authorstat->list; > t = info->committer_date; > date = gmtime(&t); > period->trunc(date); > - tmp = xstrdup(period->pretty(date)); > - item = string_list_insert(items, tmp); > - free(tmp); > + item = string_list_insert(items, period->pretty(date)); > item->util++; > authorstat->total++; > cgit_free_commitinfo(info); > -- > 2.6.1