Skip to content

Commit 4a8993f

Browse files
author
huangly
committed
Remove that Heap_1.c unnecessary judgment and code logic
1 parent ef22228 commit 4a8993f

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

portable/MemMang/heap_1.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,7 @@ void * pvPortMalloc( size_t xWantedSize )
7878
{
7979
if( xWantedSize & portBYTE_ALIGNMENT_MASK )
8080
{
81-
/* Byte alignment required. Check for overflow. */
82-
if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize )
83-
{
84-
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
85-
}
86-
else
87-
{
88-
xWantedSize = 0;
89-
}
81+
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
9082
}
9183
}
9284
#endif /* if ( portBYTE_ALIGNMENT != 1 ) */
@@ -101,8 +93,7 @@ void * pvPortMalloc( size_t xWantedSize )
10193

10294
/* Check there is enough room left for the allocation and. */
10395
if( ( xWantedSize > 0 ) && /* valid size */
104-
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE ) &&
105-
( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) ) /* Check for overflow. */
96+
( ( xNextFreeByte + xWantedSize ) < configADJUSTED_HEAP_SIZE )) /* check for overflow */
10697
{
10798
/* Return the next free byte then increment the index past this
10899
* block. */

0 commit comments

Comments
 (0)