Remove that Heap_1.c unnecessary judgment and code logic

This commit is contained in:
huangly 2024-05-29 17:52:05 +08:00
parent ef22228bda
commit 4a8993f47f

View file

@ -78,15 +78,7 @@ void * pvPortMalloc( size_t xWantedSize )
{ {
if( xWantedSize & portBYTE_ALIGNMENT_MASK ) if( xWantedSize & portBYTE_ALIGNMENT_MASK )
{ {
/* Byte alignment required. Check for overflow. */ xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize )
{
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
}
else
{
xWantedSize = 0;
}
} }
} }
#endif /* if ( portBYTE_ALIGNMENT != 1 ) */ #endif /* if ( portBYTE_ALIGNMENT != 1 ) */
@ -101,8 +93,7 @@ void * pvPortMalloc( size_t xWantedSize )
/* Check there is enough room left for the allocation and. */ /* Check there is enough room left for the allocation and. */
if( ( xWantedSize > 0 ) && /* valid size */ if( ( xWantedSize > 0 ) && /* valid size */
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE )) /* check for overflow */
( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */
{ {
/* Return the next free byte then increment the index past this /* Return the next free byte then increment the index past this
* block. */ * block. */