summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2018-01-24 11:14:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-01-24 20:55:26 (GMT)
commit27a41841ec7f83b3b1078c400f149bc536e796a4 (patch)
tree9663160e3ddc11a66c54d68ba0df9ff0326dbfa7
parent4a2854f77cc913fafc7f3191a61b343280979643 (diff)
downloadgit-27a41841ec7f83b3b1078c400f149bc536e796a4.zip
git-27a41841ec7f83b3b1078c400f149bc536e796a4.tar.gz
git-27a41841ec7f83b3b1078c400f149bc536e796a4.tar.bz2
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>
-rw-r--r--refs/packed-backend.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 26b8901..8beb996 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -620,8 +620,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
/* If the file has a header line, process it: */
if (snapshot->buf < snapshot->eof && *snapshot->buf == '#') {
- struct strbuf tmp = STRBUF_INIT;
- char *p, *eol;
+ char *tmp, *p, *eol;
struct string_list traits = STRING_LIST_INIT_NODUP;
eol = memchr(snapshot->buf, '\n',
@@ -631,9 +630,9 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
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,
snapshot->buf,
snapshot->eof - snapshot->buf);
@@ -653,7 +652,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
snapshot->start = eol + 1;
string_list_clear(&traits, 0);
- strbuf_release(&tmp);
+ free(tmp);
}
verify_buffer_safe(snapshot);