Deallocate a varying-length structure

A varying-length structure has a default memory duration of the current memory duration. To conserve resources, use the mi_var_free() function to explicitly deallocate the varying-length structure when your DataBlade® API module no longer needs it.

The mi_var_free() function is the destructor function for a varying-length structure. It frees both parts of a varying-length structure: the varying-length descriptor and the data portion.
Restriction: Do not use the DataBlade API memory-management function mi_free() to deallocate a varying-length structure. The mi_free() function does not deallocate both parts of a varying-length structure.

Use mi_var_free() to deallocate varying-length structures that you have allocated with mi_new_var() or mi_var_copy(). Do not use it to deallocate any varying-length structure that the DataBlade API has allocated.

The mi_var_free() function accepts as an argument a pointer to an mi_lvarchar value. The following call to mi_var_free() deallocates the mi_lvarchar varying-length structure that A sample mi_new_var() call allocates:
mi_var_free(new_lvarch);
To deallocate other varying-length data types, cast the mi_lvarchar argument of mi_var_free() to the appropriate varying-length type, as the following code fragment shows:
mi_sendrecv *new_sndrcv;
...
new_sndrcv = (mi_sendrecv *)mi_new_var(30);
...
mi_var_free((mi_lvarchar *)new_sndrcv);

This cast is not strictly required, but many compilers recommend it and it does improve clarity of purpose.