Create a new variable xAllocatedBlockSize for traceMALLOC()

This commit is contained in:
WangGaoJie 2024-06-12 16:16:07 +08:00
parent 2d5c193a0f
commit 3a6f50487e
14 changed files with 83 additions and 45 deletions

View file

@ -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. */
@ -360,7 +361,7 @@ void * pvPortMalloc( size_t xWantedSize )
}
else
{
xWantedSize = pxBlock->xBlockSize;
mtCOVERAGE_TEST_MARKER();
}
xFreeBytesRemaining -= pxBlock->xBlockSize;
@ -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,10 +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 ) xWantedSize;
( void ) xAllocatedBlockSize;
#if ( secureconfigUSE_MALLOC_FAILED_HOOK == 1 )
{