From: Antoine Pelisse <apelisse@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Rich Midwinter <rich.midwinter@gmail.com>,
Antoine Pelisse <apelisse@gmail.com>
Subject: [PATCH 2/5] mailmap: Remove buffer length limit in map_user
Date: Tue, 11 Dec 2012 23:21:30 +0100 [thread overview]
Message-ID: <1355264493-8298-3-git-send-email-apelisse@gmail.com> (raw)
In-Reply-To: <1355264493-8298-1-git-send-email-apelisse@gmail.com>
Remove the hard limit set by mail buffer in map_user and
use the strbuf API to replace it.
Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
---
mailmap.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/mailmap.c b/mailmap.c
index ea4b471..e636278 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -193,7 +193,8 @@ int map_user(struct string_list *map,
char *end_of_email;
struct string_list_item *item;
struct mailmap_entry *me;
- char buf[1024], *mailbuf;
+ struct strbuf buf = STRBUF_INIT;
+ char *mailbuf;
int i;
/* figure out space requirement for email */
@@ -204,15 +205,13 @@ int map_user(struct string_list *map,
if (!end_of_email)
return 0;
}
- if (end_of_email - email + 1 < sizeof(buf))
- mailbuf = buf;
- else
- mailbuf = xmalloc(end_of_email - email + 1);
/* downcase the email address */
+ strbuf_grow(&buf, end_of_email - email);
for (i = 0; i < end_of_email - email; i++)
- mailbuf[i] = tolower(email[i]);
- mailbuf[i] = 0;
+ strbuf_addch(&buf, tolower(email[i]));
+ strbuf_addch(&buf, 0);
+ mailbuf = strbuf_detach(&buf, 0);
debug_mm("map_user: map '%s' <%s>\n", name, mailbuf);
item = string_list_lookup(map, mailbuf);
@@ -226,8 +225,7 @@ int map_user(struct string_list *map,
item = subitem;
}
}
- if (mailbuf != buf)
- free(mailbuf);
+ free(mailbuf);
if (item != NULL) {
struct mailmap_info *mi = (struct mailmap_info *)item->util;
if (mi->name == NULL && (mi->email == NULL || maxlen_email == 0)) {
--
1.8.1.rc1.5.g7e0651a
next prev parent reply other threads:[~2012-12-11 22:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-11 22:21 [PATCH 0/5] Allow git log to use mailmap file Antoine Pelisse
2012-12-11 22:21 ` [PATCH 1/5] Use split_ident_line to parse author and committer Antoine Pelisse
2012-12-11 22:21 ` Antoine Pelisse [this message]
2012-12-11 22:21 ` [PATCH 3/5] mailmap: Add mailmap structure to rev_info and pp Antoine Pelisse
2012-12-11 22:21 ` [PATCH 4/5] pretty: Use mailmap to display username and email Antoine Pelisse
2012-12-11 22:46 ` Junio C Hamano
2012-12-12 13:27 ` Antoine Pelisse
2012-12-11 22:21 ` [PATCH 5/5] log: Add --use-mailmap option Antoine Pelisse
2012-12-12 11:58 ` Antoine Pelisse
2012-12-12 17:58 ` Junio C Hamano
2012-12-11 22:33 ` [PATCH 0/5] Allow git log to use mailmap file Junio C Hamano
2012-12-11 22:41 ` Rich Midwinter
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=1355264493-8298-3-git-send-email-apelisse@gmail.com \
--to=apelisse@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rich.midwinter@gmail.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).