aboutsummaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-28 15:46:53 -0400
committerJunio C Hamano <gitster@pobox.com>2017-03-30 14:59:50 -0700
commit0dc3b035e03a4028a22cd2a8b5f21086e3227047 (patch)
treed29e39d4d746d27859ce62adee63272ded49c0cb /combine-diff.c
parent5b1ef2cef4ff9d3213ec81465b99affb4a7c8083 (diff)
downloadgit-0dc3b035e03a4028a22cd2a8b5f21086e3227047.tar.gz
git-0dc3b035e03a4028a22cd2a8b5f21086e3227047.tar.xz
combine-diff: replace malloc/snprintf with xstrfmt
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>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 59501db99..d3560573a 100644
--- 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;