### _udestroy -- Destroy a Heap

Format

>     #include <umalloc.h>
>     int _udestroy(Heap_t heap, int force);

Language Level: Extension
_udestroy destroys the heap you specify. It also returns the heap's memory to the system by calling the release_fn you supplied to _ucreate when you created the heap. If you did not supply a release_fn, _udestroy simply marks the heap as destroyed so no further operations can be performed. You must then return all the memory in the heap to the system.

Note: Whether you provide a release_fn, you must always return the initial block of memory (that you provided to _ucreate) to the system.

The force parameter controls the behavior of _udestroy if all allocated objects from the heap have not been freed. If you specify _FORCE for this parameter, _udestroy destroys the heap regardless of whether allocated objects remain in that process or in any other process that shares the heap. If you specify !_FORCE, the heap will not be destroyed if any objects are still allocated from it.

Typically, you call _uclose to close the heap before you destroy it. After you have destroyed a heap, any attempt to access it will have undefined results.

You cannot destroy the IBM C and C++ Compilers runtime heap (_RUNTIME_HEAP).

Return Value
_udestroy returns 0 whether the heap was destroyed or not. If the heap passed to it is not valid, _udestroy returns a nonzero value.

Example

Example

Memory Management

_uaddmem -- Add Memory to a Heap
_ucreate -- Create a Memory Heap
_uopen -- Open Heap for Use
_uclose -- Close Heap from Use
<umalloc.h>