Skip to content

Commit 34b4066

Browse files
committed
fixed XMALLOC, XFREE and XREALLOC definitions for embOS
1 parent 8c6de41 commit 34b4066

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

wolfssl/wolfcrypt/settings.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,9 +2052,17 @@ extern void uITRON4_free(void *p) ;
20522052
#include "RTOS.h"
20532053
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
20542054
!defined(WOLFSSL_STATIC_MEMORY)
2055-
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_HEAP_malloc((s)))
2056-
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_HEAP_free((p)))
2057-
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_HEAP_realloc(((p), (n)))
2055+
/* Per the user manual of embOS https://www.segger.com/downloads/embos/UM01001
2056+
this API has changed with V5. */
2057+
#if (OS_VERSION >= 50000U)
2058+
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_HEAP_malloc((s)))
2059+
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_HEAP_free((p)))
2060+
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_HEAP_realloc((p), (n)))
2061+
#else
2062+
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_malloc((s)))
2063+
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_free((p)))
2064+
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_realloc((p), (n)))
2065+
#endif
20582066
#endif
20592067
#endif
20602068

wolfssl/wolfcrypt/types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ typedef struct w64wrapper {
556556
#endif
557557
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
558558
#endif /* WOLFSSL_DEBUG_MEMORY */
559+
#elif defined(WOLFSSL_EMBOS) && !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
560+
/* settings.h solve this case already. Avoid redefinition. */
559561
#elif (!defined(FREERTOS) && !defined(FREERTOS_TCP)) || defined(WOLFSSL_TRACK_MEMORY)
560562
#ifdef WOLFSSL_DEBUG_MEMORY
561563
#define XMALLOC(s, h, t) ((void)(h), (void)(t), wolfSSL_Malloc((s), __func__, __LINE__))

0 commit comments

Comments
 (0)