Format
#include <umalloc.h> int _uflush(Heap_t uh, size_t poolsize);
Language Level: Extension
_uflush reduces the size of the pool, and returns the unused
memory blocks to the main heap for future allocations. _uflush is
like _heapmin, except that _uflush
passes a size to flush a particular allocation size, and _uflush
does not return the unused memory to the system. A size of 0 will
flush the entire pool.
Note: Because sizes are rounded up to the _ALIGNx boundary, objects of sizes other than the specified size may be freed by the call to _uflush.
Return Value
If successful, _uflush returns 0.
Example
In this example, _upool is invoked to create a transparent memory
pool, and then _uflush is called to return all the storage to the
heap.
#include <stdlib.h> #include <stdio.h> #include <umalloc.h>
int main(void)
{
char *p1, *p2;
if (_upool(_RUNTIME_HEAP, 1, 128, 1000, _ALIGN8))
printf ("Function _upool failed.\n");
p1 = (char*)malloc(32); /* allocation will be from pool */ p2 = (char*)malloc(200); /* allocation will not be from pool */ free(p1); free(p2);
if (_uflush(_RUNTIME_HEAP, 0)) /* flush the entire pool */
printf ("Function _uflush failed.\n");
return 0; }
![]()
_heapmin -- Release Unused Memory from
Default Heap
_upool -- Create a Memory Pool
<stdlib.h>
<stdio.h>
<umalloc.h>