From 4a8993f47f6b363ef6626f27f7af096d5c5e5455 Mon Sep 17 00:00:00 2001 From: huangly Date: Wed, 29 May 2024 17:52:05 +0800 Subject: [PATCH] Remove that Heap_1.c unnecessary judgment and code logic --- portable/MemMang/heap_1.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c index 68f14bd37..56dc67bf8 100644 --- a/portable/MemMang/heap_1.c +++ b/portable/MemMang/heap_1.c @@ -78,15 +78,7 @@ void * pvPortMalloc( size_t xWantedSize ) { if( xWantedSize & portBYTE_ALIGNMENT_MASK ) { - /* Byte alignment required. Check for overflow. */ - if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) - { - xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } - else - { - xWantedSize = 0; - } + xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); } } #endif /* if ( portBYTE_ALIGNMENT != 1 ) */ @@ -101,8 +93,7 @@ void * pvPortMalloc( size_t xWantedSize ) /* Check there is enough room left for the allocation and. */ if( ( xWantedSize > 0 ) && /* valid size */ - ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) && - ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */ + ( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE )) /* check for overflow */ { /* Return the next free byte then increment the index past this * block. */