void *mi_zalloc (size)
mi_integer size;
The mi_zalloc( ) function allocates size number of bytes of user memory for a DataBlade API module. The mi_zalloc( ) function behaves exactly like mi_alloc( ) except that mi_zalloc( ) fills the allocated block of memory with zeroes before the function returns the pointer to the memory. The mi_zalloc( ) function is a constructor function for user memory.
The mi_zalloc( ) function allocates the memory in the current memory duration. By default, the current default duration is PER_ROUTINE. In C UDRs, the database server also automatically frees memory allocated with mi_zalloc( ) when an exception is raised.
In client LIBMI applications, mi_zalloc( ) works exactly as malloc( ) does: it allocates storage on the heap of the client process. However, the database server does not perform any automatic garbage collection. Therefore, the client LIBMI application must use mi_free( ) to explicitly free all allocations that mi_zalloc( ) makes.
Client LIBMI applications can use either DataBlade API memory-management functions or system memory-management functions (such as malloc( )).
The mi_zalloc( ) function returns a pointer to the newly allocated memory. Cast this pointer to match the structure of the user-defined buffer or structure that you allocate. A DataBlade API module can use mi_free( ) to free memory allocated by mi_zalloc( ) when that memory is no longer needed.
The mi_zalloc( ) function does not throw an MI_Exception event when it encounters a runtime error. Therefore, it does not cause callbacks to be invoked.
See also the descriptions of mi_alloc( ), mi_dalloc( ), mi_free( ), and mi_switch_mem_duration( ).
For more information about memory allocation and memory durations, see the IBM Informix: DataBlade API Programmer's Guide.