Skip to content

Commit cdd2c62

Browse files
committed
realloc(): Log original memory ptr too.
To alloc complete memory alloc flow tracing.
1 parent 4a74d31 commit cdd2c62

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/malloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
5959
free(ptr);
6060
return NULL;
6161
}
62-
ptr = realloc(ptr, new_num_bytes);
63-
if (ptr == NULL) {
62+
void *new_ptr = realloc(ptr, new_num_bytes);
63+
if (new_ptr == NULL) {
6464
printf("could not allocate memory, reallocating %d bytes\n", new_num_bytes);
6565
return NULL;
6666
}
@@ -75,8 +75,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
7575
current_bytes_allocated += diff;
7676
UPDATE_PEAK();
7777
#endif
78-
DEBUG_printf("realloc %d, %d : %p\n", old_num_bytes, new_num_bytes, ptr);
79-
return ptr;
78+
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
79+
return new_ptr;
8080
}
8181

8282
void m_free(void *ptr, int num_bytes) {

0 commit comments

Comments
 (0)