Hi Dan,
By default, wolfSSL maps XMALLOC(), XFREE(), and XREALLOC() to wolfSSL_Malloc(), wolfSSL_Free(), and wolfSSL_Realloc() respectively, in wolfssl/ctaocrypt/types.h:
/* default C runtime, can install different routines at runtime via cbs */
#include <wolfssl/ctaocrypt/memory.h>
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
The way this is set up allows the user application to register their own memory functions at runtime via the memory callbacks that wolfSSL provides, but defaults to just using malloc(), free(), and realloc() if no custom memory functions have been registered. For example, wolfSSL_Malloc(), which is used by default, is located in ctaocrypt/src/memory.c:
void* wolfSSL_Malloc(size_t size)
{
void* res = 0;
if (malloc_function)
res = malloc_function(size);
else
res = malloc(size);
#ifdef WOLFSSL_MALLOC_CHECK
if(res == NULL)
err_sys("wolfSSL_malloc") ;
#endif
return res;
}
Best Regards,
Chris