mirror of
https://github.com/git/git
synced 2024-09-13 13:24:41 +00:00
create_snapshot(): use xmemdupz()
rather than a strbuf
It's lighter weight. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4a2854f77c
commit
27a41841ec
|
@ -620,8 +620,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
|
||||||
|
|
||||||
/* If the file has a header line, process it: */
|
/* If the file has a header line, process it: */
|
||||||
if (snapshot->buf < snapshot->eof && *snapshot->buf == '#') {
|
if (snapshot->buf < snapshot->eof && *snapshot->buf == '#') {
|
||||||
struct strbuf tmp = STRBUF_INIT;
|
char *tmp, *p, *eol;
|
||||||
char *p, *eol;
|
|
||||||
struct string_list traits = STRING_LIST_INIT_NODUP;
|
struct string_list traits = STRING_LIST_INIT_NODUP;
|
||||||
|
|
||||||
eol = memchr(snapshot->buf, '\n',
|
eol = memchr(snapshot->buf, '\n',
|
||||||
|
@ -631,9 +630,9 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
|
||||||
snapshot->buf,
|
snapshot->buf,
|
||||||
snapshot->eof - snapshot->buf);
|
snapshot->eof - snapshot->buf);
|
||||||
|
|
||||||
strbuf_add(&tmp, snapshot->buf, eol - snapshot->buf);
|
tmp = xmemdupz(snapshot->buf, eol - snapshot->buf);
|
||||||
|
|
||||||
if (!skip_prefix(tmp.buf, "# pack-refs with:", (const char **)&p))
|
if (!skip_prefix(tmp, "# pack-refs with:", (const char **)&p))
|
||||||
die_invalid_line(refs->path,
|
die_invalid_line(refs->path,
|
||||||
snapshot->buf,
|
snapshot->buf,
|
||||||
snapshot->eof - snapshot->buf);
|
snapshot->eof - snapshot->buf);
|
||||||
|
@ -653,7 +652,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
|
||||||
snapshot->start = eol + 1;
|
snapshot->start = eol + 1;
|
||||||
|
|
||||||
string_list_clear(&traits, 0);
|
string_list_clear(&traits, 0);
|
||||||
strbuf_release(&tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_buffer_safe(snapshot);
|
verify_buffer_safe(snapshot);
|
||||||
|
|
Loading…
Reference in a new issue