Topic: [SOLVED] Use of XMALLOC

I'm assuming that I should use XMALLOC instead of malloc when allocating space on the heap.  But what should I use for type?  The enum value DYNAMIC_TYPE_TMP_BUFFER is mentioned, is this suitable for allocating a byte array of a certain length that I will later free using XFREE?

What are the risks of using malloc and free instead?

Share

Re: [SOLVED] Use of XMALLOC

Hi gawiz,

XMALLOC/XFREE/XREALLOC are part of the wolfSSL memory abstraction layer.  By default, these just map down to malloc/free/realloc, but depending on if you are using one of our OS ports, these are mapped instead to that OS's memory functions.  Whenever wolfSSL needs to allocate, reallocate, of free memory internally, we call XMALLOC/XFREE/XREALLOC.

Users can also define XMALLOC/XFREE/XREALLOC in their settings.h or user_settings.h (if HAVE_USER_SETTINGS is defined), mapping them to their own custom memory handlers.

Since these are used internally by wolfSSL, at your own application level, you are still free to use your own memory functions directly (ie: malloc, etc.).

Best Regards,
Chris

Re: [SOLVED] Use of XMALLOC

Thanks Chris.  That helps...

Share