Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
create_snapshot(): use `xmemdupz()` rather than a strbuf
author
Michael Haggerty
<mhagger@alum.mit.edu>
Wed, 24 Jan 2018 11:14:12 +0000
(12:14 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 24 Jan 2018 20:55:26 +0000
(12:55 -0800)
It's lighter weight.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/packed-backend.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4a2854f
)
diff --git
a/refs/packed-backend.c
b/refs/packed-backend.c
index 26b890118cb1de1335ee5ba388645516b5446dcf..8beb99652f5d79a92cc7b61359bc08ab3067bfca 100644
(file)
--- 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 == '#') {
/* 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',
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);
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);
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);
snapshot->start = eol + 1;
string_list_clear(&traits, 0);
-
strbuf_release(&
tmp);
+
free(
tmp);
}
verify_buffer_safe(snapshot);
}
verify_buffer_safe(snapshot);