Add counter access to memory debug API

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2022-01-04 10:23:34 +01:00
parent a93aa580dc
commit 35415a0c46
2 changed files with 25 additions and 0 deletions

View file

@ -90,6 +90,19 @@ void mbedtls_memory_buffer_set_verify( int verify );
*/
void mbedtls_memory_buffer_alloc_status( void );
/**
* \brief Get the number of alloc/free so far.
*
* \param alloc_count Number of allocations.
* \param free_count Number of frees.
*/
void mbedtls_memory_buffer_alloc_count_get( size_t *alloc_count, size_t *free_count );
/**
* \brief Reset alloc/free counters.
*/
void mbedtls_memory_buffer_alloc_count_reset( void );
/**
* \brief Get the peak heap usage so far
*

View file

@ -522,6 +522,18 @@ void mbedtls_memory_buffer_alloc_status( void )
}
}
void mbedtls_memory_buffer_alloc_count_get( size_t *alloc_count, size_t *free_count )
{
*alloc_count = heap.alloc_count;
*free_count = heap.free_count;
}
void mbedtls_memory_buffer_alloc_count_reset( void )
{
heap.alloc_count = 0;
heap.free_count = 0;
}
void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks )
{
*max_used = heap.maximum_used;