Skip to content

Commit 7832a4b

Browse files
author
huangly
committed
Remove useless alignment calculations and increase heap usage size
1 parent 4a8993f commit 7832a4b

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

portable/MemMang/heap_1.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
5151
#endif
5252

53-
/* A few bytes might be lost to byte aligning the heap start address. */
54-
#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
55-
5653
/* Allocate the memory for the heap. */
5754
#if ( configAPPLICATION_ALLOCATED_HEAP == 1 )
5855

@@ -93,7 +90,7 @@ void * pvPortMalloc( size_t xWantedSize )
9390

9491
/* Check there is enough room left for the allocation and. */
9592
if( ( xWantedSize > 0 ) && /* valid size */
96-
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE )) /* check for overflow */
93+
( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE )) /* check for overflow */
9794
{
9895
/* Return the next free byte then increment the index past this
9996
* block. */
@@ -139,7 +136,7 @@ void vPortInitialiseBlocks( void )
139136

140137
size_t xPortGetFreeHeapSize( void )
141138
{
142-
return( configADJUSTED_HEAP_SIZE - xNextFreeByte );
139+
return( configTOTAL_HEAP_SIZE - xNextFreeByte );
143140
}
144141

145142
/*-----------------------------------------------------------*/

portable/MemMang/heap_2.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
5757
#endif
5858

59-
/* A few bytes might be lost to byte aligning the heap start address. */
60-
#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
61-
6259
/* Assumes 8bit bytes! */
6360
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
6461

@@ -111,7 +108,7 @@ PRIVILEGED_DATA static BlockLink_t xStart, xEnd;
111108

112109
/* Keeps track of the number of free bytes remaining, but says nothing about
113110
* fragmentation. */
114-
PRIVILEGED_DATA static size_t xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
111+
PRIVILEGED_DATA static size_t xFreeBytesRemaining = configTOTAL_HEAP_SIZE;
115112

116113
/* Indicates whether the heap has been initialised or not. */
117114
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
@@ -376,13 +373,13 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
376373
xStart.xBlockSize = ( size_t ) 0;
377374

378375
/* xEnd is used to mark the end of the list of free blocks. */
379-
xEnd.xBlockSize = configADJUSTED_HEAP_SIZE;
376+
xEnd.xBlockSize = configTOTAL_HEAP_SIZE;
380377
xEnd.pxNextFreeBlock = NULL;
381378

382379
/* To start with there is a single free block that is sized to take up the
383380
* entire heap space. */
384381
pxFirstFreeBlock = ( BlockLink_t * ) pucAlignedHeap;
385-
pxFirstFreeBlock->xBlockSize = configADJUSTED_HEAP_SIZE;
382+
pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;
386383
pxFirstFreeBlock->pxNextFreeBlock = &xEnd;
387384
}
388385
/*-----------------------------------------------------------*/
@@ -394,7 +391,7 @@ static void prvHeapInit( void ) /* PRIVILEGED_FUNCTION */
394391
*/
395392
void vPortHeapResetState( void )
396393
{
397-
xFreeBytesRemaining = configADJUSTED_HEAP_SIZE;
394+
xFreeBytesRemaining = configTOTAL_HEAP_SIZE;
398395

399396
xHeapHasBeenInitialised = pdFALSE;
400397
}

0 commit comments

Comments
 (0)