Lines Matching +full:- +full:- +full:check

5  * SPDX-License-Identifier: MIT
67 /* Check if multiplying a and b will result in overflow. */
70 /* Check if adding a and b will result in overflow. */
71 #define heapADD_WILL_OVERFLOW( a, b ) ( ( a ) > ( heapSIZE_MAX - ( b ) ) )
77 …BLOCK_ALLOCATED_BITMASK ( ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 ) )
79 #define heapBLOCK_IS_ALLOCATED( pxBlock ) ( ( ( pxBlock->xBlockSize ) & heapBLOCK_ALLOCATED_…
80 #define heapALLOCATE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) |= heapBLOCK_ALLOCATED_B…
81 #define heapFREE_BLOCK( pxBlock ) ( ( pxBlock->xBlockSize ) &= ~heapBLOCK_ALLOCATED_…
83 /*-----------------------------------------------------------*/
89 * heap - probably so it can be placed in a special segment or address. */
103 /*-----------------------------------------------------------*/
119 /*-----------------------------------------------------------*/
123 static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT -
136 /*-----------------------------------------------------------*/
172 … xAdditionalRequiredSize = portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ); in pvPortMalloc()
198 /* Check the block size we are trying to allocate is not so large that the in pvPortMalloc()
200 * structure is used to determine who owns the block - the application or in pvPortMalloc()
211 … while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) in pvPortMalloc()
214 pxBlock = pxBlock->pxNextFreeBlock; in pvPortMalloc()
221 /* Return the memory space pointed to - jumping over the in pvPortMalloc()
223 … pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize ); in pvPortMalloc()
227 pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; in pvPortMalloc()
231 if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) in pvPortMalloc()
242 pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; in pvPortMalloc()
243 pxBlock->xBlockSize = xWantedSize; in pvPortMalloc()
253 xFreeBytesRemaining -= pxBlock->xBlockSize; in pvPortMalloc()
264 /* The block is being returned - it is allocated and owned in pvPortMalloc()
267 pxBlock->pxNextFreeBlock = NULL; in pvPortMalloc()
305 /*-----------------------------------------------------------*/
316 puc -= xHeapStructSize; in vPortFree()
322 configASSERT( pxLink->pxNextFreeBlock == NULL ); in vPortFree()
326 if( pxLink->pxNextFreeBlock == NULL ) in vPortFree()
328 /* The block is being returned to the heap - it is no longer in vPortFree()
333 … ( void ) memset( puc + xHeapStructSize, 0, pxLink->xBlockSize - xHeapStructSize ); in vPortFree()
340 xFreeBytesRemaining += pxLink->xBlockSize; in vPortFree()
341 traceFREE( pv, pxLink->xBlockSize ); in vPortFree()
358 /*-----------------------------------------------------------*/
364 /*-----------------------------------------------------------*/
370 /*-----------------------------------------------------------*/
376 /*-----------------------------------------------------------*/
395 /*-----------------------------------------------------------*/
409 uxAddress += ( portBYTE_ALIGNMENT - 1 ); in prvHeapInit()
411 xTotalHeapSize -= ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) ucHeap ); in prvHeapInit()
424 uxAddress -= xHeapStructSize; in prvHeapInit()
427 pxEnd->xBlockSize = 0; in prvHeapInit()
428 pxEnd->pxNextFreeBlock = NULL; in prvHeapInit()
433 …pxFirstFreeBlock->xBlockSize = ( size_t ) ( uxAddress - ( portPOINTER_SIZE_TYPE ) pxFirstFreeBlock… in prvHeapInit()
434 pxFirstFreeBlock->pxNextFreeBlock = pxEnd; in prvHeapInit()
436 /* Only one block exists - and it covers the entire usable heap space. */ in prvHeapInit()
437 xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; in prvHeapInit()
438 xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; in prvHeapInit()
440 /*-----------------------------------------------------------*/
449 …for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator- in prvInsertBlockIntoFreeList()
458 if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) in prvInsertBlockIntoFreeList()
460 pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; in prvInsertBlockIntoFreeList()
472 if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) in prvInsertBlockIntoFreeList()
474 if( pxIterator->pxNextFreeBlock != pxEnd ) in prvInsertBlockIntoFreeList()
477 pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; in prvInsertBlockIntoFreeList()
478 pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; in prvInsertBlockIntoFreeList()
482 pxBlockToInsert->pxNextFreeBlock = pxEnd; in prvInsertBlockIntoFreeList()
487 pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; in prvInsertBlockIntoFreeList()
496 pxIterator->pxNextFreeBlock = pxBlockToInsert; in prvInsertBlockIntoFreeList()
503 /*-----------------------------------------------------------*/
524 if( pxBlock->xBlockSize > xMaxSize ) in vPortGetHeapStats()
526 xMaxSize = pxBlock->xBlockSize; in vPortGetHeapStats()
529 if( pxBlock->xBlockSize < xMinSize ) in vPortGetHeapStats()
531 xMinSize = pxBlock->xBlockSize; in vPortGetHeapStats()
536 pxBlock = pxBlock->pxNextFreeBlock; in vPortGetHeapStats()
542 pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; in vPortGetHeapStats()
543 pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; in vPortGetHeapStats()
544 pxHeapStats->xNumberOfFreeBlocks = xBlocks; in vPortGetHeapStats()
548 pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; in vPortGetHeapStats()
549 pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; in vPortGetHeapStats()
550 pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; in vPortGetHeapStats()
551 pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; in vPortGetHeapStats()
555 /*-----------------------------------------------------------*/