Copy data into a user-allocated buffer

The mi_var_to_buffer() function copies the data of an existing varying-length structure into a user-allocated buffer. The function copies data up to the data length specified in the varying-length descriptor. You can obtain the current data length with the mi_get_varlen() function.

The following code fragment copies the contents of the varying-length structure in Copying a null-terminated string into a varying-length structure into the my_buffer user-allocated buffer
mi_lvarchar *lvarch;
char *my_buffer;
...
my_buffer = (char *)mi_alloc(mi_get_varlen(lvarch));
mi_var_to_buffer(lvarch, my_buffer);
After the successful completion of mi_var_to_buffer(), the my_buffer variable points to the following string, which is not null terminated:
A varying-length structure stores data in a data portion, which is separate 
from the varying-length structure.
Important: Do not assume that the data in the user-allocated buffer is null terminated. The mi_var_to_buffer() function does not append a null terminator to the data in the character buffer.