mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 17:17:44 -04:00
adjustments for consistency
This commit is contained in:
parent
8aa5f3bba2
commit
3c56f1186a
2 changed files with 38 additions and 44 deletions
|
@ -134,25 +134,27 @@ void * pvPortMalloc( size_t xWantedSize )
|
||||||
|
|
||||||
/* The wanted size must be increased so it can contain a BlockLink_t
|
/* The wanted size must be increased so it can contain a BlockLink_t
|
||||||
* structure in addition to the requested amount of bytes. */
|
* structure in addition to the requested amount of bytes. */
|
||||||
if( xWantedSize > 0 )
|
if( ( xWantedSize > 0 ) &&
|
||||||
{
|
( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) /* Overflow check */
|
||||||
/* Ensure xWantedSize will never wrap after adjustment, even if we need
|
|
||||||
* an alignment adjustment */
|
|
||||||
if( ( xWantedSize > 0 ) && ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) )
|
|
||||||
{
|
{
|
||||||
xWantedSize += heapSTRUCT_SIZE;
|
xWantedSize += heapSTRUCT_SIZE;
|
||||||
|
|
||||||
/* Ensure that blocks are always aligned to the required number of bytes. */
|
/* Byte alignment required. (check for overflow again) */
|
||||||
if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0 )
|
if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) )
|
||||||
|
> xWantedSize )
|
||||||
{
|
{
|
||||||
/* Byte alignment required. */
|
|
||||||
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
|
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
|
||||||
|
configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xWantedSize = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* If the requested size is too large to handle we force an error */
|
/* If the requested size is too large to handle we force an error */
|
||||||
xWantedSize = 0;
|
xWantedSize = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
|
if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,17 +136,14 @@ void * pvPortMalloc( size_t xWantedSize )
|
||||||
* kernel, so it must be free. */
|
* kernel, so it must be free. */
|
||||||
if( ( xWantedSize & xBlockAllocatedBit ) == 0 )
|
if( ( xWantedSize & xBlockAllocatedBit ) == 0 )
|
||||||
{
|
{
|
||||||
/* The wanted size is increased so it can contain a BlockLink_t
|
/* The wanted size must be increased so it can contain a BlockLink_t
|
||||||
* structure in addition to the requested amount of bytes. */
|
* structure in addition to the requested amount of bytes. */
|
||||||
if( xWantedSize > 0 )
|
if( ( xWantedSize > 0 ) &&
|
||||||
{
|
( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) /* Overflow check */
|
||||||
/* Check for overflow */
|
|
||||||
if ( ( xWantedSize + xHeapStructSize ) > xWantedSize )
|
|
||||||
{
|
{
|
||||||
xWantedSize += xHeapStructSize;
|
xWantedSize += xHeapStructSize;
|
||||||
|
|
||||||
/* Ensure that blocks are always aligned to the required number
|
/* Ensure that blocks are always aligned */
|
||||||
* of bytes. */
|
|
||||||
if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
|
if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
|
||||||
{
|
{
|
||||||
/* Byte alignment required. (check for overflow again) */
|
/* Byte alignment required. (check for overflow again) */
|
||||||
|
@ -170,11 +167,6 @@ void * pvPortMalloc( size_t xWantedSize )
|
||||||
{
|
{
|
||||||
xWantedSize = 0;
|
xWantedSize = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
|
if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue