Syntax
#include <umalloc.h> int _ustats(Heap_t heap, _HEAPSTATS *hpinfo);Description
The _HEAPSTATS structure type is defined in <umalloc.h>. The members it contains and the information that _ustats stores in each is as follows: compact break=fit.
If successful, _ustats returns 0. A nonzero return code indicates failure. Passing _ustats a heap that is not valid results in undefined behavior.
This example creates a heap and allocates memory from it. It then calls _ustats to print out information about the heap.
#include <stdlib.h>#include <stdio.h>
#include <umalloc.h>
int main(void)
{
Heap_t myheap;
_HEAPSTATS myheap_stat;
char *ptr;
/* Use default heap as user heap */
myheap = _udefault(NULL);
if (NULL == (ptr = _umalloc(myheap, 100))) {
puts("Cannot allocate memory from user heap.");
exit(EXIT_FAILURE);
}
if (0 != _ustats(myheap, &myheap_stat)) {
puts("_ustats failed.");
exit(EXIT_FAILURE);
}
printf ("_provided: %u\n", myheap_stat._provided);
printf ("_used : %u\n", myheap_stat._used);
printf ("_shared : %u\n", myheap_stat._shared);
printf ("_max_free: %u\n", myheap_stat._max_free);
free(ptr);
return 0;
/****************************************************************************
The output should be similar to :
_provided: 65264
_used : 14304
_shared : 0
_max_free: 50960
****************************************************************************/
}
Related Information