提交 8bd9fd50 编写于 作者: M Matthieu Moy 提交者: Junio C Hamano

xmalloc: include size in the failure message

Out-of-memory errors can either be actual lack of memory, or bugs (like
code trying to call xmalloc(-1) by mistake). A little more information
may help tracking bugs reported by users.
Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 8c67c392
......@@ -40,7 +40,8 @@ void *xmalloc(size_t size)
if (!ret && !size)
ret = malloc(1);
if (!ret)
die("Out of memory, malloc failed");
die("Out of memory, malloc failed (tried to allocate %lu bytes)",
(unsigned long)size);
}
#ifdef XMALLOC_POISON
memset(ret, 0xA5, size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册