Allocate named memory

To handle dynamic memory allocation of named memory, use one of the following DataBlade® API memory-management functions.
Memory-Allocation Task DataBlade API Function
To allocate named memory with a specified memory duration mi_named_alloc()
To allocate named memory with a specified memory duration that is initialized with zeros mi_named_zalloc()
These named-memory-allocation functions allocate a block of named memory of a specified size and a specified memory duration. You can use both regular and advanced memory durations for named memory. Usually, named-memory allocations are at memory durations longer than PER_COMMAND. With PER_ROUTINE and PER_COMMAND memory durations, you can use the MI_FPARAM structure to store information. You must ensure that the memory duration is sufficiently long that all UDRs that need to access it can access it.
Tip: These named-memory-management functions do not use the current memory duration.

If the allocation of the named-memory block is successful, these functions store a pointer to the allocated block in their mem_ptr argument. The UDR that allocated the named-memory block can access this named memory through this address. However, this address is deallocated when the routine invocation completes. Other UDRs must use the block name to access the named-memory block. For more information, see Obtain a block of allocated named memory.

These DataBlade API memory-management functions work correctly with the transaction management and memory reclamation of the database server. They provide the same advantages as the user-memory-management functions (see Allocate user memory (Server)). In addition, they provide the advantage that the named-memory block can be accessed by a name, which facilitates access to the memory across UDRs.