Skip to content
Snippets Groups Projects
Commit cdd2c62e authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

realloc(): Log original memory ptr too.

To alloc complete memory alloc flow tracing.
parent 4a74d31e
No related branches found
No related tags found
No related merge requests found
...@@ -59,8 +59,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) { ...@@ -59,8 +59,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
free(ptr); free(ptr);
return NULL; return NULL;
} }
ptr = realloc(ptr, new_num_bytes); void *new_ptr = realloc(ptr, new_num_bytes);
if (ptr == NULL) { if (new_ptr == NULL) {
printf("could not allocate memory, reallocating %d bytes\n", new_num_bytes); printf("could not allocate memory, reallocating %d bytes\n", new_num_bytes);
return NULL; return NULL;
} }
...@@ -75,8 +75,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) { ...@@ -75,8 +75,8 @@ void *m_realloc(void *ptr, int old_num_bytes, int new_num_bytes) {
current_bytes_allocated += diff; current_bytes_allocated += diff;
UPDATE_PEAK(); UPDATE_PEAK();
#endif #endif
DEBUG_printf("realloc %d, %d : %p\n", old_num_bytes, new_num_bytes, ptr); DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
return ptr; return new_ptr;
} }
void m_free(void *ptr, int num_bytes) { void m_free(void *ptr, int num_bytes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment