Skip to content

Commit e64a26d

Browse files
authored
Merge pull request #7274 from SKlimaRA/SKlimaRA/fix-embos-heap-allocation-macros
fixed XMALLOC, XFREE and XREALLOC definitions for embOS
2 parents a77c6d1 + c5a5acd commit e64a26d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

wolfssl/wolfcrypt/settings.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,9 +2123,17 @@ extern void uITRON4_free(void *p) ;
21232123
#include "RTOS.h"
21242124
#if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
21252125
!defined(WOLFSSL_STATIC_MEMORY)
2126-
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_HEAP_malloc((s)))
2127-
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_HEAP_free((p)))
2128-
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_HEAP_realloc(((p), (n)))
2126+
/* Per the user manual of embOS https://www.segger.com/downloads/embos/UM01001
2127+
* this API has changed with V5. */
2128+
#if (OS_VERSION >= 50000U)
2129+
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_HEAP_malloc((s)))
2130+
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_HEAP_free((p)))
2131+
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_HEAP_realloc((p), (n)))
2132+
#else
2133+
#define XMALLOC(s, h, type) ((void)(h), (void)(type), OS_malloc((s)))
2134+
#define XFREE(p, h, type) ((void)(h), (void)(type), OS_free((p)))
2135+
#define XREALLOC(p, n, h, t) ((void)(h), (void)(t), OS_realloc((p), (n)))
2136+
#endif
21292137
#endif
21302138
#endif
21312139

wolfssl/wolfcrypt/types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,10 @@ typedef struct w64wrapper {
558558
#endif
559559
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
560560
#endif /* WOLFSSL_DEBUG_MEMORY */
561+
#elif defined(WOLFSSL_EMBOS) && !defined(XMALLOC_USER) \
562+
&& !defined(NO_WOLFSSL_MEMORY) \
563+
&& !defined(WOLFSSL_STATIC_MEMORY)
564+
/* settings.h solve this case already. Avoid redefinition. */
561565
#elif (!defined(FREERTOS) && !defined(FREERTOS_TCP)) || defined(WOLFSSL_TRACK_MEMORY)
562566
#ifdef WOLFSSL_DEBUG_MEMORY
563567
#define XMALLOC(s, h, t) ((void)(h), (void)(t), wolfSSL_Malloc((s), __func__, __LINE__))

0 commit comments

Comments
 (0)