From 280eb768f2346fe236dabfe456d80b19c19d8995 Mon Sep 17 00:00:00 2001 From: QiKai Date: Mon, 21 Dec 2020 17:23:09 +0800 Subject: [PATCH] Fix the defect that Heap_1.c may waste first 8 bytes of ucHeap[] --- portable/MemMang/heap_1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c index a1e96bdf3..db7f94df7 100644 --- a/portable/MemMang/heap_1.c +++ b/portable/MemMang/heap_1.c @@ -94,7 +94,7 @@ void * pvPortMalloc( size_t xWantedSize ) if( pucAlignedHeap == NULL ) { /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT - 1 ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); } /* Check there is enough room left for the allocation and. */