]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Patch from Robert O'Callahan:
authorNicholas Nethercote <njn@valgrind.org>
Sun, 12 Oct 2008 19:51:41 +0000 (19:51 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 12 Oct 2008 19:51:41 +0000 (19:51 +0000)
  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

coregrind/m_mallocfree.c

index d9976718e7523fec50e6789bb2f392214be6c20c..c775a163f2f15a1de229a6c4658989238c118755 100644 (file)
@@ -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));