Lines Matching +full:- +full:- +full:check
5 * SPDX-License-Identifier: MIT
31 * across multiple non-contigous blocks and combines (coalescences) adjacent
101 /* Check if multiplying a and b will result in overflow. */
104 /* Check if adding a and b will result in overflow. */
105 #define heapADD_WILL_OVERFLOW( a, b ) ( ( a ) > ( heapSIZE_MAX - ( b ) ) )
111 …BLOCK_ALLOCATED_BITMASK ( ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ) )
113 #define heapBLOCK_IS_ALLOCATED( pxBlock ) ( ( ( pxBlock->xBlockSize ) & heapBLOCK_ALLOCATED_…
114 #define heapALLOCATE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) |= heapBLOCK_ALLOCATED_B…
115 #define heapFREE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) &= ~heapBLOCK_ALLOCATED_…
117 /*-----------------------------------------------------------*/
127 /*-----------------------------------------------------------*/
137 /*-----------------------------------------------------------*/
141 static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT -…
154 /*-----------------------------------------------------------*/
183 … xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ); in pvPortMalloc()
209 /* Check the block size we are trying to allocate is not so large that the in pvPortMalloc()
211 * structure is used to determine who owns the block - the application or in pvPortMalloc()
222 … while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) in pvPortMalloc()
225 pxBlock = pxBlock->pxNextFreeBlock; in pvPortMalloc()
232 /* Return the memory space pointed to - jumping over the in pvPortMalloc()
234 … pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); in pvPortMalloc()
238 pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; in pvPortMalloc()
242 if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) in pvPortMalloc()
252 pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; in pvPortMalloc()
253 pxBlock->xBlockSize = xWantedSize; in pvPortMalloc()
263 xFreeBytesRemaining -= pxBlock->xBlockSize; in pvPortMalloc()
274 /* The block is being returned - it is allocated and owned in pvPortMalloc()
277 pxBlock->pxNextFreeBlock = NULL; in pvPortMalloc()
314 /*-----------------------------------------------------------*/
325 puc -= xHeapStructSize; in vPortFree()
331 configASSERT( pxLink->pxNextFreeBlock == NULL ); in vPortFree()
335 if( pxLink->pxNextFreeBlock == NULL ) in vPortFree()
337 /* The block is being returned to the heap - it is no longer in vPortFree()
342 … ( void ) memset( puc + xHeapStructSize, 0, pxLink->xBlockSize - xHeapStructSize ); in vPortFree()
349 xFreeBytesRemaining += pxLink->xBlockSize; in vPortFree()
350 traceFREE( pv, pxLink->xBlockSize ); in vPortFree()
367 /*-----------------------------------------------------------*/
373 /*-----------------------------------------------------------*/
379 /*-----------------------------------------------------------*/
398 /*-----------------------------------------------------------*/
407 …for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator-… in prvInsertBlockIntoFreeList()
416 if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) in prvInsertBlockIntoFreeList()
418 pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; in prvInsertBlockIntoFreeList()
430 if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) in prvInsertBlockIntoFreeList()
432 if( pxIterator->pxNextFreeBlock != pxEnd ) in prvInsertBlockIntoFreeList()
435 pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; in prvInsertBlockIntoFreeList()
436 pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; in prvInsertBlockIntoFreeList()
440 pxBlockToInsert->pxNextFreeBlock = pxEnd; in prvInsertBlockIntoFreeList()
445 pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; in prvInsertBlockIntoFreeList()
454 pxIterator->pxNextFreeBlock = pxBlockToInsert; in prvInsertBlockIntoFreeList()
461 /*-----------------------------------------------------------*/
478 while( pxHeapRegion->xSizeInBytes > 0 ) in vPortDefineHeapRegions()
480 xTotalRegionSize = pxHeapRegion->xSizeInBytes; in vPortDefineHeapRegions()
483 xAddress = ( portPOINTER_SIZE_TYPE ) pxHeapRegion->pucStartAddress; in vPortDefineHeapRegions()
487 xAddress += ( portBYTE_ALIGNMENT - 1 ); in vPortDefineHeapRegions()
491 …xTotalRegionSize -= ( size_t ) ( xAddress - ( portPOINTER_SIZE_TYPE ) pxHeapRegion->pucStartAddres… in vPortDefineHeapRegions()
510 /* Check blocks are passed in with increasing start addresses. */ in vPortDefineHeapRegions()
521 xAddress -= xHeapStructSize; in vPortDefineHeapRegions()
524 pxEnd->xBlockSize = 0; in vPortDefineHeapRegions()
525 pxEnd->pxNextFreeBlock = NULL; in vPortDefineHeapRegions()
531 …pxFirstFreeBlockInRegion->xBlockSize = ( size_t ) ( xAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFr… in vPortDefineHeapRegions()
532 pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd; in vPortDefineHeapRegions()
538 pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion; in vPortDefineHeapRegions()
541 xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize; in vPortDefineHeapRegions()
551 /* Check something was actually defined before it is accessed. */ in vPortDefineHeapRegions()
554 /*-----------------------------------------------------------*/
575 if( pxBlock->xBlockSize > xMaxSize ) in vPortGetHeapStats()
577 xMaxSize = pxBlock->xBlockSize; in vPortGetHeapStats()
581 * each region - the block is only used to link to the next in vPortGetHeapStats()
583 if( pxBlock->xBlockSize != 0 ) in vPortGetHeapStats()
585 if( pxBlock->xBlockSize < xMinSize ) in vPortGetHeapStats()
587 xMinSize = pxBlock->xBlockSize; in vPortGetHeapStats()
593 pxBlock = pxBlock->pxNextFreeBlock; in vPortGetHeapStats()
599 pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; in vPortGetHeapStats()
600 pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; in vPortGetHeapStats()
601 pxHeapStats->xNumberOfFreeBlocks = xBlocks; in vPortGetHeapStats()
605 pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; in vPortGetHeapStats()
606 pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; in vPortGetHeapStats()
607 pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; in vPortGetHeapStats()
608 pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; in vPortGetHeapStats()
612 /*-----------------------------------------------------------*/