4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-28 05:37:04 +08:00

Merge pull request #1920 from armink/fix_mem

[kernel][mem] Improve some ISR check range.
This commit is contained in:
Bernard Xiong 2018-10-23 18:39:52 +08:00 committed by GitHub
commit bf537189a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -261,11 +261,11 @@ void *rt_malloc(rt_size_t size)
rt_size_t ptr, ptr2; rt_size_t ptr, ptr2;
struct heap_mem *mem, *mem2; struct heap_mem *mem, *mem2;
RT_DEBUG_NOT_IN_INTERRUPT;
if (size == 0) if (size == 0)
return RT_NULL; return RT_NULL;
RT_DEBUG_NOT_IN_INTERRUPT;
if (size != RT_ALIGN(size, RT_ALIGN_SIZE)) if (size != RT_ALIGN(size, RT_ALIGN_SIZE))
RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n", RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n",
size, RT_ALIGN(size, RT_ALIGN_SIZE))); size, RT_ALIGN(size, RT_ALIGN_SIZE)));
@ -513,8 +513,6 @@ void *rt_calloc(rt_size_t count, rt_size_t size)
{ {
void *p; void *p;
RT_DEBUG_NOT_IN_INTERRUPT;
/* allocate 'count' objects of size 'size' */ /* allocate 'count' objects of size 'size' */
p = rt_malloc(count * size); p = rt_malloc(count * size);
@ -536,10 +534,11 @@ void rt_free(void *rmem)
{ {
struct heap_mem *mem; struct heap_mem *mem;
RT_DEBUG_NOT_IN_INTERRUPT;
if (rmem == RT_NULL) if (rmem == RT_NULL)
return; return;
RT_DEBUG_NOT_IN_INTERRUPT;
RT_ASSERT((((rt_uint32_t)rmem) & (RT_ALIGN_SIZE - 1)) == 0); RT_ASSERT((((rt_uint32_t)rmem) & (RT_ALIGN_SIZE - 1)) == 0);
RT_ASSERT((rt_uint8_t *)rmem >= (rt_uint8_t *)heap_ptr && RT_ASSERT((rt_uint8_t *)rmem >= (rt_uint8_t *)heap_ptr &&
(rt_uint8_t *)rmem < (rt_uint8_t *)heap_end); (rt_uint8_t *)rmem < (rt_uint8_t *)heap_end);