Fixes for better supporting FREERTOS with and without static memory. Added fallback case to use pvPortMalloc/vPortFree when heap ptr not available.

This commit is contained in:
David Garske
2018-02-06 09:28:27 -08:00
parent 81b64742f3
commit 9afd26e853
2 changed files with 11 additions and 3 deletions

View File

@ -533,7 +533,11 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
}
#else
#ifndef WOLFSSL_NO_MALLOC
res = malloc(size);
#ifdef FREERTOS
res = pvPortMalloc(size);
#else
res = malloc(size);
#endif
#else
WOLFSSL_MSG("No heap hint found to use and no malloc");
#ifdef WOLFSSL_DEBUG_MEMORY
@ -667,7 +671,11 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
}
#endif
#ifndef WOLFSSL_NO_MALLOC
free(ptr);
#ifdef FREERTOS
vPortFree(ptr);
#else
free(ptr);
#endif
#else
WOLFSSL_MSG("Error trying to call free when turned off");
#endif /* WOLFSSL_NO_MALLOC */

View File

@ -246,7 +246,7 @@
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));}
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
#endif /* WOLFSSL_DEBUG_MEMORY */
#else
#elif !defined(FREERTOS) && !defined(FREERTOS_TCP)
#ifdef WOLFSSL_DEBUG_MEMORY
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__))
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);}