Skip to content

Commit 8bd9fd5

Browse files
moygitster
authored andcommitted
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: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c67c39 commit 8bd9fd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

wrapper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void *xmalloc(size_t size)
4040
if (!ret && !size)
4141
ret = malloc(1);
4242
if (!ret)
43-
die("Out of memory, malloc failed");
43+
die("Out of memory, malloc failed (tried to allocate %lu bytes)",
44+
(unsigned long)size);
4445
}
4546
#ifdef XMALLOC_POISON
4647
memset(ret, 0xA5, size);

0 commit comments

Comments
 (0)