msize function?

Hello there, I was wondering either there is a msize function available that would determine the amount of dynamically allocated memory with freertos malloc port function? I would appreciate all help.

msize function?

FreeRTOS keeps memory allocation in the port layer – so the answer is ‘it depends on which memory allocator you are using’. If you are using heap1, heap2, heap4 or heap5 that come with the kernel download then the answer is no – there is no msize function – but (in heap4 and heap5 at least) each block starts with the following structure: ~~~ typedef struct ABLOCKLINK { struct ABLOCKLINK pxNextFreeBlock; /<< The next free block in the list. / size_t xBlockSize; /<< The size of the free block. */ } BlockLink_t; ~~~ so you could create one quite easily. This structure is BEFORE the memory returned by malloc(). If you look at the implementation of vPortFree() in heap_4.c you will see how to access it. here is a snippet of the code, you will see that you have to mask off the most significant bit to get the size: ~~~ if( pv != NULL ) { /* The memory being freed will have an BlockLink_t structure immediately before it. */ puc -= xHeapStructSize;
    /* This casting is to keep the compiler from issuing warnings. */
    pxLink = ( void * ) puc;

    /* Check the block is actually allocated. */
    configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
    configASSERT( pxLink->pxNextFreeBlock == NULL );
~~~

msize function?

Thank you!