From: "Adeodato Simó" <dato@net.com.org.es>
To: git@vger.kernel.org, gitster@pobox.com
Cc: "Adeodato Simó" <dato@net.com.org.es>
Subject: [PATCH] builtin-shortlog.c: use string_list_append() instead of duplicating its code
Date: Wed, 24 Dec 2008 17:34:36 +0100 [thread overview]
Message-ID: <1230136476-11081-1-git-send-email-dato@net.com.org.es> (raw)
Also, when clearing the "onelines" string lists, do not free the "util"
member: with string_list_append() is not initialized to any value (and
was being initialized to NULL previously anyway).
NB: The duplicated code in builtin-shortlog.c predated the appearance of
string_list_append().
Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---
builtin-shortlog.c | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index d03f14f..4c5d761 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -36,7 +36,6 @@ static void insert_one_record(struct shortlog *log,
const char *dot3 = log->common_repo_prefix;
char *buffer, *p;
struct string_list_item *item;
- struct string_list *onelines;
char namebuf[1024];
size_t len;
const char *eol;
@@ -104,16 +103,7 @@ static void insert_one_record(struct shortlog *log,
}
}
- onelines = item->util;
- if (onelines->nr >= onelines->alloc) {
- onelines->alloc = alloc_nr(onelines->nr);
- onelines->items = xrealloc(onelines->items,
- onelines->alloc
- * sizeof(struct string_list_item));
- }
-
- onelines->items[onelines->nr].util = NULL;
- onelines->items[onelines->nr++].string = buffer;
+ string_list_append(buffer, item->util);
}
static void read_from_stdin(struct shortlog *log)
@@ -323,7 +313,7 @@ void shortlog_output(struct shortlog *log)
}
onelines->strdup_strings = 1;
- string_list_clear(onelines, 1);
+ string_list_clear(onelines, 0);
free(onelines);
log->list.items[i].util = NULL;
}
--
1.6.0.4
next reply other threads:[~2008-12-24 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-24 16:34 Adeodato Simó [this message]
2008-12-30 12:20 ` [PATCH] builtin-shortlog.c: use string_list_append() instead of duplicating its code Johannes Schindelin
2008-12-30 20:25 ` [PATCH v2] builtin-shortlog.c: use string_list_append(), and don't strdup unnecessarily Adeodato Simó
2008-12-30 21:01 ` [PATCH v3] " Adeodato Simó
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1230136476-11081-1-git-send-email-dato@net.com.org.es \
--to=dato@net.com.org.es \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).