#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
\r
/* Block sizes must not get too small. */\r
-#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize * 2 ) )\r
+#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )\r
\r
/* Assumes 8bit bytes! */\r
#define heapBITS_PER_BYTE ( ( size_t ) 8 )\r
\r
/* The size of the structure placed at the beginning of each allocated memory\r
block must by correctly byte aligned. */\r
-static const size_t xHeapStructSize = ( ( sizeof( BlockLink_t ) + ( ( ( size_t ) portBYTE_ALIGNMENT_MASK ) - ( size_t ) 1 ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK ) );\r
+static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
\r
/* Create a couple of list links to mark the start and end of the list. */\r
static BlockLink_t xStart, *pxEnd = NULL;\r
cast is used to prevent byte alignment warnings from the\r
compiler. */\r
pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );\r
- configASSERT( ( ( ( uint32_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r
+ configASSERT( ( ( ( size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );\r
\r
/* Calculate the sizes of two blocks split from the\r
single block. */\r
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
\r
/* Block sizes must not get too small. */\r
-#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( uxHeapStructSize << 1 ) )\r
+#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )\r
\r
/* Assumes 8bit bytes! */\r
#define heapBITS_PER_BYTE ( ( size_t ) 8 )\r
\r
/* The size of the structure placed at the beginning of each allocated memory\r
block must by correctly byte aligned. */\r
-static const uint32_t uxHeapStructSize = ( ( sizeof ( BlockLink_t ) + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );\r
+static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );\r
\r
/* Create a couple of list links to mark the start and end of the list. */\r
static BlockLink_t xStart, *pxEnd = NULL;\r
\r
/* Keeps track of the number of free bytes remaining, but says nothing about\r
fragmentation. */\r
-static size_t xFreeBytesRemaining = 0;\r
-static size_t xMinimumEverFreeBytesRemaining = 0;\r
+static size_t xFreeBytesRemaining = 0U;\r
+static size_t xMinimumEverFreeBytesRemaining = 0U;\r
\r
/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize\r
member of an BlockLink_t structure is set then the block belongs to the\r
structure in addition to the requested amount of bytes. */\r
if( xWantedSize > 0 )\r
{\r
- xWantedSize += uxHeapStructSize;\r
+ xWantedSize += xHeapStructSize;\r
\r
/* Ensure that blocks are always aligned to the required number\r
of bytes. */\r
{\r
/* Return the memory space pointed to - jumping over the\r
BlockLink_t structure at its start. */\r
- pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + uxHeapStructSize );\r
+ pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );\r
\r
/* This block is being returned for use so must be taken out\r
of the list of free blocks. */\r
{\r
/* The memory being freed will have an BlockLink_t structure immediately\r
before it. */\r
- puc -= uxHeapStructSize;\r
+ puc -= xHeapStructSize;\r
\r
/* This casting is to keep the compiler from issuing warnings. */\r
pxLink = ( void * ) puc;\r
uint8_t *pucAlignedHeap;\r
size_t xTotalRegionSize, xTotalHeapSize = 0;\r
BaseType_t xDefinedRegions = 0;\r
-uint32_t ulAddress;\r
+size_t xAddress;\r
const HeapRegion_t *pxHeapRegion;\r
\r
/* Can only call once! */\r
xTotalRegionSize = pxHeapRegion->xSizeInBytes;\r
\r
/* Ensure the heap region starts on a correctly aligned boundary. */\r
- ulAddress = ( uint32_t ) pxHeapRegion->pucStartAddress;\r
- if( ( ulAddress & portBYTE_ALIGNMENT_MASK ) != 0 )\r
+ xAddress = ( size_t ) pxHeapRegion->pucStartAddress;\r
+ if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )\r
{\r
- ulAddress += ( portBYTE_ALIGNMENT - 1 );\r
- ulAddress &= ~portBYTE_ALIGNMENT_MASK;\r
+ xAddress += ( portBYTE_ALIGNMENT - 1 );\r
+ xAddress &= ~portBYTE_ALIGNMENT_MASK;\r
\r
/* Adjust the size for the bytes lost to alignment. */\r
- xTotalRegionSize -= ulAddress - ( uint32_t ) pxHeapRegion->pucStartAddress;\r
+ xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;\r
}\r
\r
- pucAlignedHeap = ( uint8_t * ) ulAddress;\r
+ pucAlignedHeap = ( uint8_t * ) xAddress;\r
\r
/* Set xStart if it has not already been set. */\r
if( xDefinedRegions == 0 )\r
configASSERT( pxEnd != NULL );\r
\r
/* Check blocks are passed in with increasing start addresses. */\r
- configASSERT( ulAddress > ( uint32_t ) pxEnd );\r
+ configASSERT( xAddress > ( size_t ) pxEnd );\r
}\r
\r
/* Remember the location of the end marker in the previous region, if\r
\r
/* pxEnd is used to mark the end of the list of free blocks and is\r
inserted at the end of the region space. */\r
- ulAddress = ( ( uint32_t ) pucAlignedHeap ) + xTotalRegionSize;\r
- ulAddress -= uxHeapStructSize;\r
- ulAddress &= ~portBYTE_ALIGNMENT_MASK;\r
- pxEnd = ( BlockLink_t * ) ulAddress;\r
+ xAddress = ( ( size_t ) pucAlignedHeap ) + xTotalRegionSize;\r
+ xAddress -= xHeapStructSize;\r
+ xAddress &= ~portBYTE_ALIGNMENT_MASK;\r
+ pxEnd = ( BlockLink_t * ) xAddress;\r
pxEnd->xBlockSize = 0;\r
pxEnd->pxNextFreeBlock = NULL;\r
\r
sized to take up the entire heap region minus the space taken by the\r
free block structure. */\r
pxFirstFreeBlockInRegion = ( BlockLink_t * ) pucAlignedHeap;\r
- pxFirstFreeBlockInRegion->xBlockSize = ulAddress - ( uint32_t ) pxFirstFreeBlockInRegion;\r
+ pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion;\r
pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;\r
\r
/* If this is not the first region that makes up the entire heap space\r