1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-08 22:36:10 +02:00

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>
This commit is contained in:
Jeff King 2017-03-28 15:46:53 -04:00 committed by Junio C Hamano
parent 5b1ef2cef4
commit 0dc3b035e0

View File

@ -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;