Manage user memory
A C UDR allocates user memory from the database server shared memory. It is accessed by address. The provides memory-management functions to allocate user memory dynamically. These functions return a pointer to the address of the allocated memory and subsequent operations are performed on that pointer.
The following table shows the memory-management functions
that the provides
for memory operations on user memory.
| User-memory task | function |
|---|---|
| Allocating user memory | mi_alloc(), mi_dalloc(), mi_realloc(), mi_zalloc() |
| Changing the size of an existing memory block | mi_realloc() |
| Changing current memory duration | mi_switch_mem_duration() |
| Deallocating user memory | mi_free() |
Tip: The memory-management
functions execute in client LIBMI applications as well as C UDRs.
For modules
that you design to run in both client LIBMI applications and UDRs,
use these memory-management functions. For information about the behavior
of these memory-management functions in a client LIBMI application,
see Write a client LIBMI application.
The following table summarizes the memory operations for
user memory.
| Memory duration | Memory operation | Function name |
|---|---|---|
| Current® memory duration | Constructor | mi_alloc(), mi_dalloc(), mi_zalloc() |
| Current® memory duration | Destructor | mi_free() |