|
From: <sv...@va...> - 2008-10-12 19:51:47
|
Author: njn
Date: 2008-10-12 20:51:41 +0100 (Sun, 12 Oct 2008)
New Revision: 8666
Log:
Patch from Robert O'Callahan:
make realloc(NULL, size) behave like malloc(size), and make
realloc(ptr, 0) behave like free(ptr), as the real libc realloc does.
Modified:
trunk/coregrind/m_mallocfree.c
Modified: trunk/coregrind/m_mallocfree.c
===================================================================
--- trunk/coregrind/m_mallocfree.c 2008-10-12 19:50:51 UTC (rev 8665)
+++ trunk/coregrind/m_mallocfree.c 2008-10-12 19:51:41 UTC (rev 8666)
@@ -1770,6 +1770,15 @@
vg_assert(req_pszB < MAX_PSZB);
+ if (NULL == ptr) {
+ return VG_(arena_malloc)(aid, cc, req_pszB);
+ }
+
+ if (req_pszB == 0) {
+ VG_(arena_free)(aid, ptr);
+ return NULL;
+ }
+
b = get_payload_block(a, ptr);
vg_assert(blockSane(a, b));
|