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
1 changed files with 5 additions and 6 deletions

View File

@ -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);