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 <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthieu Moy committed
Aug 20, 2010 at 17:09 UTC
8bd9fd50014424643bddfde51423d42e0fc60800
1 file changed
+2
-1
wrapper.c
+2
-1
@@ -40,7 +40,8 @@ void *xmalloc(size_t size)
40
if (!ret && !size)
41
ret = malloc(1);
42
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);
45
}
46
#ifdef XMALLOC_POISON
47
memset(ret, 0xA5, size);