Skip to content

Commit 280eb76

Browse files
QKCocleandachalco
authored andcommitted
Fix the defect that Heap_1.c may waste first 8 bytes of ucHeap[]
1 parent ef4c305 commit 280eb76

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

portable/MemMang/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void * pvPortMalloc( size_t xWantedSize )
9494
if( pucAlignedHeap == NULL )
9595
{
9696
/* Ensure the heap starts on a correctly aligned boundary. */
97-
pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
97+
pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) & ucHeap[ portBYTE_ALIGNMENT - 1 ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
9898
}
9999

100100
/* Check there is enough room left for the allocation and. */

0 commit comments

Comments
 (0)