summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarmink <[email protected]>2018-10-23 16:03:17 +0800
committerarmink <[email protected]>2018-10-23 16:03:17 +0800
commitcc0f5ca1cdb124a6279cffe442407e4ff638d3cc (patch)
tree593657d0fd2713b56f59b0caa397023247a6793a
parent944220745552ab12809a7ab23cc9b6cd43ad2ce0 (diff)
[kernel][mem] Improve some ISR check range.
-rw-r--r--src/mem.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mem.c b/src/mem.c
index cb96ab9ee0..2fefb48b67 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -261,11 +261,11 @@ void *rt_malloc(rt_size_t size)
rt_size_t ptr, ptr2;
struct heap_mem *mem, *mem2;
- RT_DEBUG_NOT_IN_INTERRUPT;
-
if (size == 0)
return RT_NULL;
+ RT_DEBUG_NOT_IN_INTERRUPT;
+
if (size != RT_ALIGN(size, RT_ALIGN_SIZE))
RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n",
size, RT_ALIGN(size, RT_ALIGN_SIZE)));
@@ -513,8 +513,6 @@ void *rt_calloc(rt_size_t count, rt_size_t size)
{
void *p;
- RT_DEBUG_NOT_IN_INTERRUPT;
-
/* allocate 'count' objects of size 'size' */
p = rt_malloc(count * size);
@@ -536,10 +534,11 @@ void rt_free(void *rmem)
{
struct heap_mem *mem;
- RT_DEBUG_NOT_IN_INTERRUPT;
-
if (rmem == RT_NULL)
return;
+
+ RT_DEBUG_NOT_IN_INTERRUPT;
+
RT_ASSERT((((rt_uint32_t)rmem) & (RT_ALIGN_SIZE - 1)) == 0);
RT_ASSERT((rt_uint8_t *)rmem >= (rt_uint8_t *)heap_ptr &&
(rt_uint8_t *)rmem < (rt_uint8_t *)heap_end);