When a VLEN is read into user memory from the file, the HDF5 library performs memory allocations for each of the variable length arrays contained within the VLEN structure. This memory must be freed by the user to avoid memory leaks.
This violates the normal netCDF expectation that the user is responsible for all memory allocation. But, with VLEN arrays, the underlying HDF5 library allocates the memory for the user, and the user is responsible for deallocating that memory.
To save the user the trouble calling free() on each element of the VLEN array (i.e. the array of arrays), the nc_free_vlen function is provided.
int nc_free_vlen(nc_vlen_t *vl);
vl
NC_NOERR
NC_EBADTYPE
This example is from test program libsrc4/tst_vl.c.
/* Free the memory used in our phony data. */ for (i=0; i<DIM_LEN; i++) if (nc_free_vlen(&data[i])) ERR;