config: use strbuf_split_str instead of a temporary strbuf

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>
This commit is contained in:
Jeff King 2011-06-09 11:55:09 -04:00 коммит произвёл Junio C Hamano
Родитель 2f1d9e2b93
Коммит f77bccaeba
1 изменённых файлов: 1 добавлений и 3 удалений

Просмотреть файл

@ -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] == '=')