From: Nicholas Nethercote Date: Sun, 12 Oct 2008 19:51:41 +0000 (+0000) Subject: Patch from Robert O'Callahan: X-Git-Tag: svn/VALGRIND_3_4_0~223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d33b3e0d24beb38682e54705b3eab6fedfaa72db;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8666 --- diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index d9976718e7..c775a163f2 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -1770,6 +1770,15 @@ void* VG_(arena_realloc) ( ArenaId aid, HChar* cc, 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));