The regular memory management functions (malloc and so on) always use whatever heap is currently the default for that thread. The initial default heap for all IBM C and C++ Compilers applications is the runtime heap provided by IBM C and C++ Compilers. However, you can make your own heap the default by calling _udefault. Then all calls to the regular memory management functions allocate from your heap instead of the runtime heap.
The default heap changes only for the thread where you call _udefault. You can use a different default heap for each thread of your program if you choose.
This is useful when you want a component (such as a vendor library) to use a heap other than the IBM C and C++ Compilers runtime heap, but you can't actually alter the source code to use heap-specific calls. For example, if you set the default heap to a shared heap then call a library function that calls malloc, the library allocates storage in shared memory.
Because _udefault returns the current default heap, you can save the return value and later use it to restore the default heap you replaced. You can also change the default back to the IBM C and C++ Compilersruntime heap by calling _udefault and specifying _RUNTIME_HEAP (defined in <umalloc.h>). You can also use this macro with any of the heap-specific functions to explicitly allocate from the runtime heap.
Memory Management Functions
Managing Memory with Multiple
Memory Heaps
Types of Memory
Debugging Memory Heaps
Creating and Using a Fixed Size Heap
Creating and Using an Expandable Heap
Debugging Problems with Heap Memory
Example of Creating and Using a User Heap
Example of Creating and Using a
Shared-Memory User Heap