When a STRING is read into user memory from the file, the HDF5 library performs memory allocations for each of the variable length character arrays contained within the STRING 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 NC_STRING 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 NC_STRING array (i.e. the array of arrays), the nc_free_string function is provided.
int nc_free_string(size_t len, char **data);
len
**data
NC_NOERR
if (nc_get_att(ncid, NC_GLOBAL, ATT_NAME, data_in)) ERR; ... if (nc_free_string(att_len, (char **)data_in)) ERR;