diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-30 03:58:17 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-30 03:58:17 +0200 |
commit | cdd2c62e07549e36dba00bc37d7ba7a4cd41ad50 (patch) | |
tree | e17cd0b521fb667acb5ce7521c08c06c4eab22db | |
parent | 4a74d31e70880599d197b9def8d1eb6fd8cad2f1 (diff) | |
download | micropython-cdd2c62e07549e36dba00bc37d7ba7a4cd41ad50.tar.gz micropython-cdd2c62e07549e36dba00bc37d7ba7a4cd41ad50.zip |
realloc(): Log original memory ptr too.
To alloc complete memory alloc flow tracing.
-rw-r--r-- | py/malloc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/py/malloc.c b/py/malloc.c index a2c55eb06b..59570243f0 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -59,8 +59,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) { free(ptr); return NULL; } - ptr = realloc(ptr, new_num_bytes); - if (ptr == NULL) { + void *new_ptr = realloc(ptr, new_num_bytes); + if (new_ptr == NULL) { printf("could not allocate memory, reallocating %d bytes\n", new_num_bytes); return NULL; } @@ -75,8 +75,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) { current_bytes_allocated += diff; UPDATE_PEAK(); #endif - DEBUG_printf("realloc %d, %d : %p\n", old_num_bytes, new_num_bytes, ptr); - return ptr; + DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr); + return new_ptr; } void m_free(void *ptr, int num_bytes) { |