提交 4afdf44d 编写于 作者: B Bernard Xiong

add RT_KERNEL_MALLOC/FREE

上级 608bf2cb
...@@ -155,6 +155,15 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ ...@@ -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_MASK (RT_MM_PAGE_SIZE - 1)
#define RT_MM_PAGE_BITS 12 #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 * @addtogroup Error
*/ */
......
...@@ -128,7 +128,7 @@ void rt_thread_idle_excute(void) ...@@ -128,7 +128,7 @@ void rt_thread_idle_excute(void)
else else
#endif #endif
/* release thread's stack */ /* release thread's stack */
rt_free(thread->stack_addr); RT_KERNEL_FREE(thread->stack_addr);
/* delete thread object */ /* delete thread object */
rt_object_delete((rt_object_t)thread); rt_object_delete((rt_object_t)thread);
#endif #endif
......
...@@ -1314,7 +1314,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag) ...@@ -1314,7 +1314,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
/* init mailbox */ /* init mailbox */
mb->size = size; 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) if (mb->msg_pool == RT_NULL)
{ {
/* delete mailbox object */ /* delete mailbox object */
...@@ -1361,7 +1361,7 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb) ...@@ -1361,7 +1361,7 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb)
#endif #endif
/* free mailbox pool */ /* free mailbox pool */
rt_free(mb->msg_pool); RT_KERNEL_FREE(mb->msg_pool);
/* delete mailbox object */ /* delete mailbox object */
rt_object_delete(&(mb->parent.parent)); rt_object_delete(&(mb->parent.parent));
...@@ -1827,7 +1827,7 @@ rt_mq_t rt_mq_create(const char *name, ...@@ -1827,7 +1827,7 @@ rt_mq_t rt_mq_create(const char *name,
mq->max_msgs = max_msgs; mq->max_msgs = max_msgs;
/* allocate message pool */ /* 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) if (mq->msg_pool == RT_NULL)
{ {
rt_mq_delete(mq); rt_mq_delete(mq);
...@@ -1881,7 +1881,7 @@ rt_err_t rt_mq_delete(rt_mq_t mq) ...@@ -1881,7 +1881,7 @@ rt_err_t rt_mq_delete(rt_mq_t mq)
#endif #endif
/* free message queue pool */ /* free message queue pool */
rt_free(mq->msg_pool); RT_KERNEL_FREE(mq->msg_pool);
/* delete message queue object */ /* delete message queue object */
rt_object_delete(&(mq->parent.parent)); rt_object_delete(&(mq->parent.parent));
......
...@@ -281,7 +281,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) ...@@ -281,7 +281,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
information = &rt_object_container[type]; information = &rt_object_container[type];
#endif #endif
object = (struct rt_object *)rt_malloc(information->object_size); object = (struct rt_object *)RT_KERNEL_MALLOC(information->object_size);
if (object == RT_NULL) if (object == RT_NULL)
{ {
/* no memory can be allocated */ /* no memory can be allocated */
...@@ -353,7 +353,7 @@ void rt_object_delete(rt_object_t object) ...@@ -353,7 +353,7 @@ void rt_object_delete(rt_object_t object)
#endif #endif
/* free the memory of object */ /* free the memory of object */
rt_free(object); RT_KERNEL_FREE(object);
} }
#endif #endif
......
...@@ -298,7 +298,7 @@ rt_thread_t rt_thread_create(const char *name, ...@@ -298,7 +298,7 @@ rt_thread_t rt_thread_create(const char *name,
if (thread == RT_NULL) if (thread == RT_NULL)
return 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) if (stack_start == RT_NULL)
{ {
/* allocate stack failure */ /* allocate stack failure */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册