summaryrefslogtreecommitdiff
path: root/src/mem.c
diff options
context:
space:
mode:
authorTangyuxin <[email protected]>2022-09-27 11:11:29 +0800
committerGitHub <[email protected]>2022-09-27 11:11:29 +0800
commitca30428ceea64e4ae76e0fe3b350107c910b2ef7 (patch)
tree4b6607b57f96e3d233df282add8fe8e52682c6d1 /src/mem.c
parent82bf18b7713232c391a9df9f5ce89631937ed717 (diff)
修复低概率终端无法输入问题 (#6464)
* [ulog] Fix the problem that the terminal cannot input * [mem] Fix NULL pointer access
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mem.c b/src/mem.c
index 14593bcfd7..221a5553e6 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -525,12 +525,6 @@ void rt_smem_free(void *rmem)
/* Get the corresponding struct rt_small_mem_item ... */
mem = (struct rt_small_mem_item *)((rt_uint8_t *)rmem - SIZEOF_STRUCT_MEM);
-
- RT_DEBUG_LOG(RT_DEBUG_MEM,
- ("release memory 0x%x, size: %d\n",
- (rt_ubase_t)rmem,
- (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
-
/* ... which has to be in a used state ... */
small_mem = MEM_POOL(mem);
RT_ASSERT(small_mem != RT_NULL);
@@ -541,6 +535,11 @@ void rt_smem_free(void *rmem)
(rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end);
RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem);
+ RT_DEBUG_LOG(RT_DEBUG_MEM,
+ ("release memory 0x%x, size: %d\n",
+ (rt_ubase_t)rmem,
+ (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
+
/* ... and is now unused. */
mem->pool_ptr = MEM_FREED();
#ifdef RT_USING_MEMTRACE