From: Junio C Hamano Date: Fri, 9 Sep 2016 04:36:01 +0000 (-0700) Subject: Merge branch 'rs/mailinfo-lib' into maint X-Git-Tag: v2.9.4~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/71165f027fed7d0d47f8cb50dd46ab4b11821a40?ds=inline;hp=-c Merge branch 'rs/mailinfo-lib' into maint Small code clean-up. * rs/mailinfo-lib: mailinfo: recycle strbuf in check_header() --- 71165f027fed7d0d47f8cb50dd46ab4b11821a40 diff --combined mailinfo.c index 9f19ca1080,44ea8638f3..e19abe3cb9 --- a/mailinfo.c +++ b/mailinfo.c @@@ -179,12 -179,6 +179,6 @@@ static void handle_content_type(struct } } - 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 +489,8 @@@ static int check_header(struct mailinf 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; } @@@ -732,7 -727,7 +727,7 @@@ static int read_one_header_line(struct struct strbuf continuation = STRBUF_INIT; /* Get the first part of the line. */ - if (strbuf_getline(line, in, '\n')) + if (strbuf_getline_lf(line, in)) return 0; /* @@@ -756,7 -751,7 +751,7 @@@ peek = fgetc(in); ungetc(peek, in); if (peek != ' ' && peek != '\t') break; - if (strbuf_getline(&continuation, in, '\n')) + if (strbuf_getline_lf(&continuation, in)) break; continuation.buf[0] = ' '; strbuf_rtrim(&continuation); @@@ -769,7 -764,7 +764,7 @@@ static int find_boundary(struct mailinfo *mi, struct strbuf *line) { - while (!strbuf_getline(line, mi->input, '\n')) { + while (!strbuf_getline_lf(line, mi->input)) { if (*(mi->content_top) && is_multipart_boundary(mi, line)) return 1; } @@@ -820,7 -815,7 +815,7 @@@ again strbuf_release(&newline); /* replenish line */ - if (strbuf_getline(line, mi->input, '\n')) + if (strbuf_getline_lf(line, mi->input)) return 0; strbuf_addch(line, '\n'); return 1; @@@ -1009,7 -1004,7 +1004,7 @@@ void setup_mailinfo(struct mailinfo *mi mi->header_stage = 1; mi->use_inbody_headers = 1; mi->content_top = mi->content; - git_config(git_mailinfo_config, &mi); + git_config(git_mailinfo_config, mi); } void clear_mailinfo(struct mailinfo *mi)