Skip to content

Commit 9779893

Browse files
author
Martin Klang
committed
prevent using malloc/calloc/realloc/free macros for non-ARM Cortex builds
1 parent b6e43fa commit 9779893

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

LibSource/basicmaths.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "fastpow.h"
55
#include "fastlog.h"
66

7+
#ifdef ARM_CORTEX
78
/* The realloc() function changes the size of the memory block pointed to */
89
/* by ptr to size bytes. The contents will be unchanged in the range from */
910
/* the start of the region up to the minimum of the old and new sizes. If */
@@ -42,6 +43,7 @@ void *pvPortCalloc(size_t nmemb, size_t size){
4243
memset(ptr, 0, xWantedSize);
4344
return ptr;
4445
}
46+
#endif
4547

4648
// todo: see
4749
// http://www.hxa.name/articles/content/fast-pow-adjustable_hxa7241_2007.html

LibSource/basicmaths.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ using std::clamp;
8686

8787
float fast_fmodf(float x, float y);
8888

89+
#ifdef ARM_CORTEX
8990
#define malloc(x) pvPortMalloc(x)
9091
#define calloc(x, y) pvPortCalloc(x, y)
9192
#define free(x) vPortFree(x)
9293
#define realloc(x, y) pvPortRealloc(x, y);
9394
void* pvPortCalloc(size_t nmemb, size_t size);
9495
void* pvPortRealloc(void *pv, size_t xWantedSize);
96+
#endif
9597

9698
#ifdef __cplusplus
9799
}

0 commit comments

Comments
 (0)