Format
#include <umalloc.h> Heap_t _uaddmem(Heap_t heap, void *block, size_t size, int clean);
Language Level: Extension
_uaddmem adds a block of memory of size
bytes into the specified user heap (created with
_ucreate).
For OS/2, you can use an OS/2 API like DosAllocMem
or by allocating it statically.
Before calling _uaddmem, you must first get the block
from the operating system, typically, for Windows, by using a
Win32 API like VirtualAlloc or by allocating it statically.
If the memory block has been initialized to 0, specify _BLOCK_CLEAN for the clean parameter. If not, specify !_BLOCK_CLEAN. (This information makes calloc and _ucalloc more efficient).
Note: Memory returned by
DosAllocMem, on OS/2, is initialized to 0.
Note: On Windows, memory
returned by VirtualAlloc is initialized to 0.
For fixed-size heaps, you must return all the blocks you added with _uaddmem to the system. (For expandable heaps, these blocks are returned by your release_fn when you call _udestroy.)
Note: For every block of memory you add, a small number of bytes from it are used to store internal information. To reduce the total amount of overhead, it is better to add a few large blocks of memory than many small blocks.
Return Value
_uaddmem returns a pointer to the heap
the memory was added to. If the heap specified is not valid,
_uaddmem returns NULL.
![]()
_ucreate -- Create a Memory
Heap
_udestroy --
Destroy a Heap
_uheapmin --
Release Unused Memory in User Heap
<umalloc.h>