mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Remove useless alignment calculations and increase heap usage size
This commit is contained in:
parent
4a8993f47f
commit
7832a4bc11
|
@ -50,9 +50,6 @@
|
||||||
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
|
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* A few bytes might be lost to byte aligning the heap start address. */
|
|
||||||
#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
|
|
||||||
|
|
||||||
/* Allocate the memory for the heap. */
|
/* Allocate the memory for the heap. */
|
||||||
#if ( configAPPLICATION_ALLOCATED_HEAP == 1 )
|
#if ( configAPPLICATION_ALLOCATED_HEAP == 1 )
|
||||||
|
|
||||||
|
@ -93,7 +90,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
||||||
|
|
||||||
/* Check there is enough room left for the allocation and. */
|
/* Check there is enough room left for the allocation and. */
|
||||||
if( ( xWantedSize > 0 ) && /* valid size */
|
if( ( xWantedSize > 0 ) && /* valid size */
|
||||||
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE )) /* check for overflow */
|
( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE )) /* check for overflow */
|
||||||
{
|
{
|
||||||
/* Return the next free byte then increment the index past this
|
/* Return the next free byte then increment the index past this
|
||||||
* block. */
|
* block. */
|
||||||
|
@ -139,7 +136,7 @@ void vPortInitialiseBlocks( void )
|
||||||
|
|
||||||
size_t xPortGetFreeHeapSize( void )
|
size_t xPortGetFreeHeapSize( void )
|
||||||
{
|
{
|
||||||
return( configADJUSTED_HEAP_SIZE - xNextFreeByte );
|
return( configTOTAL_HEAP_SIZE - xNextFreeByte );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
|
@ -56,9 +56,6 @@
|
||||||
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
|
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* A few bytes might be lost to byte aligning the heap start address. */
|
|
||||||
#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
|
|
||||||
|
|
||||||
/* Assumes 8bit bytes! */
|
/* Assumes 8bit bytes! */
|
||||||
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
|
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
|
||||||
|
|
||||||
|
@ -111,7 +108,7 @@ PRIVILEGED_DATA static BlockLink_t xStart, xEnd;
|
||||||
|
|
||||||
/* Keeps track of the number of free bytes remaining, but says nothing about
|
/* Keeps track of the number of free bytes remaining, but says nothing about
|
||||||
* fragmentation. */
|
* fragmentation. */
|
||||||
PRIVILEGED_DATA static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
|
PRIVILEGED_DATA static size_t xFreeBytesRemaining = configTOTAL_HEAP_SIZE;
|
||||||
|
|
||||||
/* Indicates whether the heap has been initialised or not. */
|
/* Indicates whether the heap has been initialised or not. */
|
||||||
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
|
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
|
||||||
|
@ -376,13 +373,13 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
xStart.xBlockSize = ( size_t ) 0;
|
xStart.xBlockSize = ( size_t ) 0;
|
||||||
|
|
||||||
/* xEnd is used to mark the end of the list of free blocks. */
|
/* xEnd is used to mark the end of the list of free blocks. */
|
||||||
xEnd.xBlockSize = configADJUSTED_HEAP_SIZE;
|
xEnd.xBlockSize = configTOTAL_HEAP_SIZE;
|
||||||
xEnd.pxNextFreeBlock = NULL;
|
xEnd.pxNextFreeBlock = NULL;
|
||||||
|
|
||||||
/* To start with there is a single free block that is sized to take up the
|
/* To start with there is a single free block that is sized to take up the
|
||||||
* entire heap space. */
|
* entire heap space. */
|
||||||
pxFirstFreeBlock = ( BlockLink_t * ) pucAlignedHeap;
|
pxFirstFreeBlock = ( BlockLink_t * ) pucAlignedHeap;
|
||||||
pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE;
|
pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;
|
||||||
pxFirstFreeBlock->pxNextFreeBlock = &xEnd;
|
pxFirstFreeBlock->pxNextFreeBlock = &xEnd;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -394,7 +391,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
|
||||||
*/
|
*/
|
||||||
void vPortHeapResetState( void )
|
void vPortHeapResetState( void )
|
||||||
{
|
{
|
||||||
xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
|
xFreeBytesRemaining = configTOTAL_HEAP_SIZE;
|
||||||
|
|
||||||
xHeapHasBeenInitialised = pdFALSE;
|
xHeapHasBeenInitialised = pdFALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue