]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - libc/bionic/malloc_debug_leak.c
merge from open-source master
[android-sdk/platform-bionic.git] / libc / bionic / malloc_debug_leak.c
index 7b8822c24abb6b88eb62914b68895cb4d910eda9..0a3a68daf2b5d400871f94fbb2f687a0b4407e33 100644 (file)
@@ -149,6 +149,8 @@ static HashEntry* record_backtrace(intptr_t* backtrace, size_t numEntries, size_
     } else {
         // create a new entry
         entry = (HashEntry*)dlmalloc(sizeof(HashEntry) + numEntries*sizeof(intptr_t));
+        if (!entry)
+            return NULL;
         entry->allocations = 1;
         entry->slot = slot;
         entry->prev = NULL;
@@ -430,8 +432,9 @@ void* chk_realloc(void* mem, size_t bytes)
     }
 
     if (new_buffer) {
-        size_t size = (bytes < old_bytes)?(bytes):(old_bytes);
-        memcpy(new_buffer, mem, size);
+        if (bytes > old_bytes)
+            bytes = old_bytes;
+        memcpy(new_buffer, mem, bytes);
         chk_free(mem);
     }
 
@@ -629,3 +632,12 @@ void* leak_memalign(size_t alignment, size_t bytes)
     }
     return base;
 }
+
+/* Initializes malloc debugging framework.
+ * See comments on MallocDebugInit in malloc_debug_common.h
+ */
+int malloc_debug_initialize(void)
+{
+    // We don't really have anything that requires initialization here.
+    return 0;
+}