Manage user memory
A C UDR allocates user memory from the database server shared memory. It is accessed by address. The DataBlade API 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 DataBlade
API provides
for memory operations on user memory.
User-memory task | DataBlade API 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 DataBlade
API memory-management
functions execute in client LIBMI applications as well as C UDRs.
For DataBlade
API 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() |