Skip to content

Commit ecf30b2

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ac617a commit ecf30b2

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

mailinfo.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
179179
}
180180
}
181181

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-
188182
static void handle_content_transfer_encoding(struct mailinfo *mi,
189183
const struct strbuf *line)
190184
{
@@ -495,7 +489,8 @@ static int check_header(struct mailinfo *mi,
495489
len = strlen("Message-Id: ");
496490
strbuf_add(&sb, line->buf + len, line->len - len);
497491
decode_header(mi, &sb);
498-
handle_message_id(mi, &sb);
492+
if (mi->add_message_id)
493+
mi->message_id = strbuf_detach(&sb, NULL);
499494
ret = 1;
500495
goto check_header_out;
501496
}

0 commit comments

Comments
 (0)