Skip to content

Commit

Permalink
config: use strbuf_split_str instead of a temporary strbuf
Browse files Browse the repository at this point in the history
This saves an allocation and copy, and also fixes a minor
memory leak.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jun 22, 2011
1 parent 2f1d9e2 commit f77bcca
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ void git_config_push_parameter(const char *text)
static int git_config_parse_parameter(const char *text,
config_fn_t fn, void *data)
{
struct strbuf tmp = STRBUF_INIT;
struct strbuf **pair;
strbuf_addstr(&tmp, text);
pair = strbuf_split_max(&tmp, '=', 2);
pair = strbuf_split_str(text, '=', 2);
if (!pair[0])
return error("bogus config parameter: %s", text);
if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=')
Expand Down

0 comments on commit f77bcca

Please sign in to comment.