display heap pointer with debug enabled

This commit is contained in:
JacobBarthelmeh
2024-10-14 10:30:34 -06:00
parent 72306b9a67
commit bc56129ed8

View File

@@ -1030,7 +1030,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
#endif
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Alloc: %p -> %u at %s:%d\n", res, (word32)size, func, line);
fprintf(stderr, "[HEAP %p] Alloc: %p -> %u at %s:%d\n", heap,
res, (word32)size, func, line);
#endif
#else
WOLFSSL_MSG("No heap hint found to use and no malloc");
@@ -1097,8 +1098,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
}
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY
else {
fprintf(stderr, "Size: %lu, Empty: %d\n", (unsigned long) size,
mem->sizeList[i]);
fprintf(stderr, "Size: %lu, Empty: %d\n",
(unsigned long) size, mem->sizeList[i]);
}
#endif
}
@@ -1114,7 +1115,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
#ifdef WOLFSSL_DEBUG_MEMORY
pt->szUsed = size;
fprintf(stderr, "Alloc: %p -> %lu at %s:%d\n", pt->buffer, size, func, line);
fprintf(stderr, "[HEAP %p] Alloc: %p -> %lu at %s:%d\n", heap,
pt->buffer, size, func, line);
#endif
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) {
@@ -1143,8 +1145,8 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
WOLFSSL_MSG("ERROR ran out of static memory");
res = NULL;
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Looking for %lu bytes at %s:%d\n", (unsigned long) size, func,
line);
fprintf(stderr, "Looking for %lu bytes at %s:%d\n",
(unsigned long) size, func, line);
#endif
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
if (DebugCb) {
@@ -1187,7 +1189,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#ifdef WOLFSSL_HEAP_TEST
if (heap == (void*)WOLFSSL_HEAP_TEST) {
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Free: %p at %s:%d\n", pt, func, line);
fprintf(stderr, "[HEAP %p] Free: %p at %s:%d\n", heap, pt, func,
line);
#endif
return free(ptr);
}
@@ -1205,6 +1208,10 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
}
#endif
#ifndef WOLFSSL_NO_MALLOC
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "[HEAP %p] Free: %p at %s:%d\n", heap, pt, func,
line);
#endif
#ifdef FREERTOS
vPortFree(ptr);
#elif defined(WOLFSSL_EMBOS)
@@ -1212,9 +1219,6 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#else
free(ptr);
#endif
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf(stderr, "Free: %p at %s:%d\n", ptr, func, line);
#endif
#else
WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */
@@ -1286,8 +1290,8 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
#endif
#ifdef WOLFSSL_DEBUG_MEMORY
fprintf (stderr, "Free: %p -> %u at %s:%d\n", pt->buffer,
pt->szUsed, func, line);
fprintf(stderr, "[HEAP %p] Free: %p -> %u at %s:%d\n", heap,
pt->buffer, pt->szUsed, func, line);
#endif
#ifndef WOLFSSL_STATIC_MEMORY_LEAN