Skip to content

Commit ee1e854

Browse files
babboysBernardXiong
authored andcommitted
[update] 使用memheap内存管理算法时,对rt_system_heap_init传入的地址进行对齐。
1 parent 3327ffa commit ee1e854

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/memheap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,13 +832,16 @@ static struct rt_memheap _heap;
832832
*/
833833
void rt_system_heap_init(void *begin_addr, void *end_addr)
834834
{
835-
RT_ASSERT((rt_uint32_t)end_addr > (rt_uint32_t)begin_addr);
835+
RT_ASSERT((rt_size_t)end_addr > (rt_size_t)begin_addr);
836+
837+
rt_size_t begin_align = RT_ALIGN((rt_size_t)begin_addr, RT_ALIGN_SIZE);
838+
rt_size_t end_align = RT_ALIGN_DOWN((rt_size_t)end_addr, RT_ALIGN_SIZE);
836839

837840
/* initialize a default heap in the system */
838841
rt_memheap_init(&_heap,
839842
"heap",
840-
begin_addr,
841-
(rt_uint32_t)end_addr - (rt_uint32_t)begin_addr);
843+
(void *)begin_align,
844+
end_align - begin_align);
842845
}
843846

844847
/**

0 commit comments

Comments
 (0)