From 5e31a2f074aa9c3350f4dc4ed93b2be4a2720c7a Mon Sep 17 00:00:00 2001 From: Cobus van Eeden <35851496+cobusve@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:21:22 -0800 Subject: [PATCH] adjustments for consistency --- portable/MemMang/heap_1.c | 8 +++++--- portable/MemMang/heap_2.c | 7 ++++--- portable/MemMang/heap_4.c | 4 ++-- portable/MemMang/heap_5.c | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c index 149ea2a88..fcc0909d5 100644 --- a/portable/MemMang/heap_1.c +++ b/portable/MemMang/heap_1.c @@ -72,16 +72,18 @@ void * pvPortMalloc( size_t xWantedSize ) void * pvReturn = NULL; static uint8_t * pucAlignedHeap = NULL; - /* Ensure that blocks are always aligned to the required number of bytes. */ + /* Ensure that blocks are always aligned. */ #if ( portBYTE_ALIGNMENT != 1 ) { if( xWantedSize & portBYTE_ALIGNMENT_MASK ) { - /* Byte alignment required, check for overflow first */ + /* Byte alignment required. Check for overflow. */ if ( (xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) )) > xWantedSize ) { xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ); - } else { + } + else + { xWantedSize = 0; } } diff --git a/portable/MemMang/heap_2.c b/portable/MemMang/heap_2.c index dbd8e2f54..2ad6c0ce6 100644 --- a/portable/MemMang/heap_2.c +++ b/portable/MemMang/heap_2.c @@ -139,7 +139,7 @@ void * pvPortMalloc( size_t xWantedSize ) { xWantedSize += heapSTRUCT_SIZE; - /* Byte alignment required. (check for overflow again) */ + /* Byte alignment required. Check for overflow. */ if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) { @@ -150,8 +150,9 @@ void * pvPortMalloc( size_t xWantedSize ) { xWantedSize = 0; } - } else { - /* If the requested size is too large to handle we force an error */ + } + else + { xWantedSize = 0; } diff --git a/portable/MemMang/heap_4.c b/portable/MemMang/heap_4.c index 7a333f207..2a1ee20ff 100644 --- a/portable/MemMang/heap_4.c +++ b/portable/MemMang/heap_4.c @@ -143,10 +143,10 @@ void * pvPortMalloc( size_t xWantedSize ) { xWantedSize += xHeapStructSize; - /* Ensure that blocks are always aligned */ + /* Ensure that blocks are always aligned. */ if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { - /* Byte alignment required. (check for overflow again) */ + /* Byte alignment required. Check for overflow. */ if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) { diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c index c4d96cb44..01e1e6ed3 100644 --- a/portable/MemMang/heap_5.c +++ b/portable/MemMang/heap_5.c @@ -150,15 +150,15 @@ void * pvPortMalloc( size_t xWantedSize ) { /* The wanted size is increased so it can contain a BlockLink_t * structure in addition to the requested amount of bytes. */ - if( ( xWantedSize > 0 ) && ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) + if( ( xWantedSize > 0 ) && + ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) /* Overflow check */ { xWantedSize += xHeapStructSize; - /* Ensure that blocks are always aligned to the required number - * of bytes. */ + /* Ensure that blocks are always aligned */ if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { - /* Byte alignment required. */ + /* Byte alignment required. Check for overflow */ if( ( xWantedSize + ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) {