mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Improve efficiency of memory allocation when the memory block is already aligned correctly.
This commit is contained in:
parent
87049ac37c
commit
fb47260e80
|
@ -113,7 +113,7 @@ typedef struct A_BLOCK_LINK
|
||||||
} xBlockLink;
|
} xBlockLink;
|
||||||
|
|
||||||
|
|
||||||
static const unsigned short heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + portBYTE_ALIGNMENT - ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
|
static const unsigned short heapSTRUCT_SIZE = ( ( sizeof ( xBlockLink ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );
|
||||||
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
|
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
|
||||||
|
|
||||||
/* Create a couple of list links to mark the start and end of the list. */
|
/* Create a couple of list links to mark the start and end of the list. */
|
||||||
|
|
|
@ -129,7 +129,7 @@ static void prvHeapInit( void );
|
||||||
|
|
||||||
/* The size of the structure placed at the beginning of each allocated memory
|
/* The size of the structure placed at the beginning of each allocated memory
|
||||||
block must by correctly byte aligned. */
|
block must by correctly byte aligned. */
|
||||||
static const unsigned short heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + portBYTE_ALIGNMENT - ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
|
static const unsigned short heapSTRUCT_SIZE = ( ( sizeof ( xBlockLink ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );
|
||||||
|
|
||||||
/* Ensure the pxEnd pointer will end up on the correct byte alignment. */
|
/* Ensure the pxEnd pointer will end up on the correct byte alignment. */
|
||||||
static const size_t xTotalHeapSize = ( ( size_t ) configADJUSTED_HEAP_SIZE ) & ( ( size_t ) ~portBYTE_ALIGNMENT_MASK );
|
static const size_t xTotalHeapSize = ( ( size_t ) configADJUSTED_HEAP_SIZE ) & ( ( size_t ) ~portBYTE_ALIGNMENT_MASK );
|
||||||
|
|
Loading…
Reference in a new issue