mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-20 01:58:32 -04:00
Fix traceMALLOC() allocated bytes (#1089)
* Fix traceMALLOC() memory count is inaccurate. (#1078) Modify xWantedSize to the size of a free block when not split blocks. Ensure that the sizes within traceMALLOC() and traceFREE() macros are equal. * Create a new variable xAllocatedBlockSize for traceMALLOC() --------- Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
This commit is contained in:
parent
663eaad1b2
commit
76eb443821
14 changed files with 98 additions and 14 deletions
|
@ -256,6 +256,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
BlockLink_t * pxNewBlockLink;
|
||||
void * pvReturn = NULL;
|
||||
size_t xAdditionalRequiredSize;
|
||||
size_t xAllocatedBlockSize = 0;
|
||||
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
* initialisation to setup the list of free blocks. */
|
||||
|
@ -374,6 +375,8 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xAllocatedBlockSize = pxBlock->xBlockSize;
|
||||
|
||||
/* The block is being returned - it is allocated and owned by
|
||||
* the application and has no "next" block. */
|
||||
secureheapALLOCATE_BLOCK( pxBlock );
|
||||
|
@ -394,7 +397,10 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
traceMALLOC( pvReturn, xWantedSize );
|
||||
traceMALLOC( pvReturn, xAllocatedBlockSize );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xAllocatedBlockSize;
|
||||
|
||||
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
{
|
||||
|
|
|
@ -256,6 +256,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
BlockLink_t * pxNewBlockLink;
|
||||
void * pvReturn = NULL;
|
||||
size_t xAdditionalRequiredSize;
|
||||
size_t xAllocatedBlockSize = 0;
|
||||
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
* initialisation to setup the list of free blocks. */
|
||||
|
@ -374,6 +375,8 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xAllocatedBlockSize = pxBlock->xBlockSize;
|
||||
|
||||
/* The block is being returned - it is allocated and owned by
|
||||
* the application and has no "next" block. */
|
||||
secureheapALLOCATE_BLOCK( pxBlock );
|
||||
|
@ -394,7 +397,10 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
traceMALLOC( pvReturn, xWantedSize );
|
||||
traceMALLOC( pvReturn, xAllocatedBlockSize );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xAllocatedBlockSize;
|
||||
|
||||
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
{
|
||||
|
|
|
@ -256,6 +256,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
BlockLink_t * pxNewBlockLink;
|
||||
void * pvReturn = NULL;
|
||||
size_t xAdditionalRequiredSize;
|
||||
size_t xAllocatedBlockSize = 0;
|
||||
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
* initialisation to setup the list of free blocks. */
|
||||
|
@ -374,6 +375,8 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xAllocatedBlockSize = pxBlock->xBlockSize;
|
||||
|
||||
/* The block is being returned - it is allocated and owned by
|
||||
* the application and has no "next" block. */
|
||||
secureheapALLOCATE_BLOCK( pxBlock );
|
||||
|
@ -394,7 +397,10 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
traceMALLOC( pvReturn, xWantedSize );
|
||||
traceMALLOC( pvReturn, xAllocatedBlockSize );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xAllocatedBlockSize;
|
||||
|
||||
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
{
|
||||
|
|
|
@ -256,6 +256,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
BlockLink_t * pxNewBlockLink;
|
||||
void * pvReturn = NULL;
|
||||
size_t xAdditionalRequiredSize;
|
||||
size_t xAllocatedBlockSize = 0;
|
||||
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
* initialisation to setup the list of free blocks. */
|
||||
|
@ -374,6 +375,8 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xAllocatedBlockSize = pxBlock->xBlockSize;
|
||||
|
||||
/* The block is being returned - it is allocated and owned by
|
||||
* the application and has no "next" block. */
|
||||
secureheapALLOCATE_BLOCK( pxBlock );
|
||||
|
@ -394,7 +397,10 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
traceMALLOC( pvReturn, xWantedSize );
|
||||
traceMALLOC( pvReturn, xAllocatedBlockSize );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xAllocatedBlockSize;
|
||||
|
||||
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
{
|
||||
|
|
|
@ -256,6 +256,7 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
BlockLink_t * pxNewBlockLink;
|
||||
void * pvReturn = NULL;
|
||||
size_t xAdditionalRequiredSize;
|
||||
size_t xAllocatedBlockSize = 0;
|
||||
|
||||
/* If this is the first call to malloc then the heap will require
|
||||
* initialisation to setup the list of free blocks. */
|
||||
|
@ -374,6 +375,8 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
xAllocatedBlockSize = pxBlock->xBlockSize;
|
||||
|
||||
/* The block is being returned - it is allocated and owned by
|
||||
* the application and has no "next" block. */
|
||||
secureheapALLOCATE_BLOCK( pxBlock );
|
||||
|
@ -394,7 +397,10 @@ void * pvPortMalloc( size_t xWantedSize )
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
traceMALLOC( pvReturn, xWantedSize );
|
||||
traceMALLOC( pvReturn, xAllocatedBlockSize );
|
||||
|
||||
/* Prevent compiler warnings when trace macros are not used. */
|
||||
( void ) xAllocatedBlockSize;
|
||||
|
||||
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue