diff --git a/include/rtdef.h b/include/rtdef.h index 8e39f2f479..a0497517b1 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -155,6 +155,15 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ #define RT_MM_PAGE_MASK (RT_MM_PAGE_SIZE - 1) #define RT_MM_PAGE_BITS 12 +/* kernel malloc definitions */ +#ifndef RT_KERNEL_MALLOC +#define RT_KERNEL_MALLOC(sz) rt_malloc(sz) +#endif + +#ifndef RT_KERNEL_FREE +#define RT_KERNEL_FREE(ptr) rt_free(ptr) +#endif + /** * @addtogroup Error */ diff --git a/src/idle.c b/src/idle.c index f03b53724d..eaf925e1ae 100644 --- a/src/idle.c +++ b/src/idle.c @@ -128,7 +128,7 @@ void rt_thread_idle_excute(void) else #endif /* release thread's stack */ - rt_free(thread->stack_addr); + RT_KERNEL_FREE(thread->stack_addr); /* delete thread object */ rt_object_delete((rt_object_t)thread); #endif diff --git a/src/ipc.c b/src/ipc.c index 4ae821a916..271eef9b97 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -1314,7 +1314,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) /* init mailbox */ mb->size = size; - mb->msg_pool = rt_malloc(mb->size * sizeof(rt_uint32_t)); + mb->msg_pool = RT_KERNEL_MALLOC(mb->size * sizeof(rt_uint32_t)); if (mb->msg_pool == RT_NULL) { /* delete mailbox object */ @@ -1361,7 +1361,7 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) #endif /* free mailbox pool */ - rt_free(mb->msg_pool); + RT_KERNEL_FREE(mb->msg_pool); /* delete mailbox object */ rt_object_delete(&(mb->parent.parent)); @@ -1827,7 +1827,7 @@ rt_mq_t rt_mq_create(const char *name, mq->max_msgs = max_msgs; /* allocate message pool */ - mq->msg_pool = rt_malloc((mq->msg_size + sizeof(struct rt_mq_message))* mq->max_msgs); + mq->msg_pool = RT_KERNEL_MALLOC((mq->msg_size + sizeof(struct rt_mq_message))* mq->max_msgs); if (mq->msg_pool == RT_NULL) { rt_mq_delete(mq); @@ -1881,7 +1881,7 @@ rt_err_t rt_mq_delete(rt_mq_t mq) #endif /* free message queue pool */ - rt_free(mq->msg_pool); + RT_KERNEL_FREE(mq->msg_pool); /* delete message queue object */ rt_object_delete(&(mq->parent.parent)); diff --git a/src/object.c b/src/object.c index add84bf3be..24cfa7b944 100644 --- a/src/object.c +++ b/src/object.c @@ -281,7 +281,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) information = &rt_object_container[type]; #endif - object = (struct rt_object *)rt_malloc(information->object_size); + object = (struct rt_object *)RT_KERNEL_MALLOC(information->object_size); if (object == RT_NULL) { /* no memory can be allocated */ @@ -353,7 +353,7 @@ void rt_object_delete(rt_object_t object) #endif /* free the memory of object */ - rt_free(object); + RT_KERNEL_FREE(object); } #endif diff --git a/src/thread.c b/src/thread.c index 6a0927eb0b..5ab9e1b0c1 100644 --- a/src/thread.c +++ b/src/thread.c @@ -298,7 +298,7 @@ rt_thread_t rt_thread_create(const char *name, if (thread == RT_NULL) return RT_NULL; - stack_start = (void *)rt_malloc(stack_size); + stack_start = (void *)RT_KERNEL_MALLOC(stack_size); if (stack_start == RT_NULL) { /* allocate stack failure */