Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
combine-diff: replace malloc/snprintf with xstrfmt
author
Jeff King
<peff@peff.net>
Tue, 28 Mar 2017 19:46:53 +0000
(15:46 -0400)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 30 Mar 2017 21:59:50 +0000
(14:59 -0700)
There's no need to use the magic "100" when a strbuf can do
it for us.
Signed-off-by: Jeff King <peff@peff.net>
combine-diff.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
5b1ef2c
)
diff --git
a/combine-diff.c
b/combine-diff.c
index 59501db99a74ab8f237766730045dda4ecd112b2..d3560573acee6ed216dca9779aa078738e9246b1 100644
(file)
--- a/
combine-diff.c
+++ b/
combine-diff.c
@@
-292,9
+292,10
@@
static char *grab_blob(const struct object_id *oid, unsigned int mode,
enum object_type type;
if (S_ISGITLINK(mode)) {
- blob = xmalloc(100);
- *size = snprintf(blob, 100,
- "Subproject commit %s\n", oid_to_hex(oid));
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "Subproject commit %s\n", oid_to_hex(oid));
+ *size = buf.len;
+ blob = strbuf_detach(&buf, NULL);
} else if (is_null_oid(oid)) {
/* deleted blob */
*size = 0;