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>
René Scharfe committed
Aug 13, 2016 at 11:05 UTC
ecf30b237cb278040f18c597c1dbdbc49793094d
1 file changed
+2
-7
mailinfo.c
+2
-7
@@ -179,12 +179,6 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
179
}
180
}
181
182
-static void handle_message_id(struct mailinfo *mi, const struct strbuf *line)
183
-{
184
- if (mi->add_message_id)
185
- mi->message_id = strdup(line->buf);
186
-}
187
-
182
static void handle_content_transfer_encoding(struct mailinfo *mi,
183
const struct strbuf *line)
184
{
@@ -495,7 +489,8 @@ static int check_header(struct mailinfo *mi,
489
len = strlen("Message-Id: ");
490
strbuf_add(&sb, line->buf + len, line->len - len);
491
decode_header(mi, &sb);
498
- handle_message_id(mi, &sb);
492
+ if (mi->add_message_id)
493
+ mi->message_id = strbuf_detach(&sb, NULL);
494
ret = 1;
495
goto check_header_out;
496
}