提交 0dc3b035 编写于 作者: J Jeff King 提交者: Junio C Hamano

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: NJeff King <peff@peff.net>
上级 5b1ef2ce
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册