diff options
author | René Scharfe <l.s.r@web.de> | 2016-08-13 11:05:42 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-08-14 04:45:24 +0200 |
commit | ecf30b237cb278040f18c597c1dbdbc49793094d (patch) | |
tree | 9b64ad559e899fd13d933b6e1856e38e8cccc863 /mailinfo.c | |
parent | mailinfo: remove calls to exit() and die() deep in the callchain (diff) | |
download | git-ecf30b237cb278040f18c597c1dbdbc49793094d.tar.xz git-ecf30b237cb278040f18c597c1dbdbc49793094d.zip |
mailinfo: recycle strbuf in check_header()
handle_message_id() duplicates the contents of the strbuf that is passed
to it. Its only caller proceeds to release the strbuf immediately after
that. Reuse it instead and make that change of object ownership more
obvious by inlining this short function.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailinfo.c')
-rw-r--r-- | mailinfo.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/mailinfo.c b/mailinfo.c index e157ca6eb5..44ea8638f3 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -179,12 +179,6 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line) } } -static void handle_message_id(struct mailinfo *mi, const struct strbuf *line) -{ - if (mi->add_message_id) - mi->message_id = strdup(line->buf); -} - static void handle_content_transfer_encoding(struct mailinfo *mi, const struct strbuf *line) { @@ -495,7 +489,8 @@ static int check_header(struct mailinfo *mi, len = strlen("Message-Id: "); strbuf_add(&sb, line->buf + len, line->len - len); decode_header(mi, &sb); - handle_message_id(mi, &sb); + if (mi->add_message_id) + mi->message_id = strbuf_detach(&sb, NULL); ret = 1; goto check_header_out; } |