summaryrefslogtreecommitdiff
path: root/components/libc/compilers/dlib
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-11-13 16:22:09 -0500
committerMeco Man <[email protected]>2021-11-15 09:55:47 -0500
commit4fe93881b071ea664b9a5b89c073ad46b9d3e312 (patch)
tree70a4203634d123d88cac48ae0142f8f664f96900 /components/libc/compilers/dlib
parent9254d1a3affdab5c329d2b8ea5bbe5a6a53e1dc9 (diff)
[dlib][armlibc] 内存函数在HEAP没有开启时增加错误警告
Diffstat (limited to 'components/libc/compilers/dlib')
-rw-r--r--components/libc/compilers/dlib/syscall_mem.c38
-rw-r--r--components/libc/compilers/dlib/syscall_write.c2
2 files changed, 34 insertions, 6 deletions
diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c
index 9c6de64455..74b960f0b9 100644
--- a/components/libc/compilers/dlib/syscall_mem.c
+++ b/components/libc/compilers/dlib/syscall_mem.c
@@ -6,27 +6,55 @@
* Change Logs:
* Date Author Notes
* 2015-01-28 Bernard first version
+ * 2021-11-13 Meco Man implement no-heap warning
*/
#include <rtthread.h>
+#include <stddef.h>
-#ifdef RT_USING_HEAP
-void *malloc(rt_size_t n)
+#ifndef RT_USING_HEAP
+#define DBG_TAG "dlib.syscall_mem"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+#define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\
+ RT_ASSERT(0);\
+ }while(0)
+#endif /* RT_USING_HEAP */
+
+void *malloc(size_t n)
{
+#ifdef RT_USING_HEAP
return rt_malloc(n);
+#else
+ _NO_HEAP_ERROR();
+ return RT_NULL;
+#endif
}
-void *realloc(void *rmem, rt_size_t newsize)
+void *realloc(void *rmem, size_t newsize)
{
+#ifdef RT_USING_HEAP
return rt_realloc(rmem, newsize);
+#else
+ _NO_HEAP_ERROR();
+ return RT_NULL;
+#endif
}
-void *calloc(rt_size_t nelem, rt_size_t elsize)
+void *calloc(size_t nelem, size_t elsize)
{
+#ifdef RT_USING_HEAP
return rt_calloc(nelem, elsize);
+#else
+ _NO_HEAP_ERROR();
+ return RT_NULL;
+#endif
}
void free(void *rmem)
{
+#ifdef RT_USING_HEAP
rt_free(rmem);
-}
+#else
+ _NO_HEAP_ERROR();
#endif
+}
diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c
index c0729afd69..9a7707e9d3 100644
--- a/components/libc/compilers/dlib/syscall_write.c
+++ b/components/libc/compilers/dlib/syscall_write.c
@@ -15,7 +15,7 @@
#include "libc.h"
#endif
-#define DBG_TAG "IAR.dlib.syscall_write"
+#define DBG_TAG "dlib.syscall_write"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>