mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-27 17:12:27 +01:00
Moved mem_track.h into wolfssl/wolfcrypt. Added new WOLFSSL_DEBUG_MEMORY option. Added documentation for using mem_track and new debug memory option.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Set these to default values initially. */
|
||||
static wolfSSL_Malloc_cb malloc_function = 0;
|
||||
static wolfSSL_Free_cb free_function = 0;
|
||||
@@ -72,15 +73,24 @@ int wolfSSL_SetAllocators(wolfSSL_Malloc_cb mf,
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
void* wolfSSL_Malloc(size_t size, const char* func, unsigned int line)
|
||||
#else
|
||||
void* wolfSSL_Malloc(size_t size)
|
||||
#endif
|
||||
{
|
||||
void* res = 0;
|
||||
|
||||
if (malloc_function)
|
||||
if (malloc_function) {
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
res = malloc_function(size, func, line);
|
||||
#else
|
||||
res = malloc_function(size);
|
||||
else
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
res = malloc(size);
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_MALLOC_CHECK
|
||||
if (res == NULL)
|
||||
@@ -90,22 +100,42 @@ void* wolfSSL_Malloc(size_t size)
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
void wolfSSL_Free(void *ptr, const char* func, unsigned int line)
|
||||
#else
|
||||
void wolfSSL_Free(void *ptr)
|
||||
#endif
|
||||
{
|
||||
if (free_function)
|
||||
if (free_function) {
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
free_function(ptr, func, line);
|
||||
#else
|
||||
free_function(ptr);
|
||||
else
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
void* wolfSSL_Realloc(void *ptr, size_t size, const char* func, unsigned int line)
|
||||
#else
|
||||
void* wolfSSL_Realloc(void *ptr, size_t size)
|
||||
#endif
|
||||
{
|
||||
void* res = 0;
|
||||
|
||||
if (realloc_function)
|
||||
if (realloc_function) {
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
res = realloc_function(ptr, size, func, line);
|
||||
#else
|
||||
res = realloc_function(ptr, size);
|
||||
else
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
res = realloc(ptr, size);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user