Next: , Previous: nc_free_vlen, Up: User Defined Data Types


5.25 Releasing Memory for an Array of Variable Length Array (VLEN) Type: nc_free_vlen

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_vlens function is provided. It frees all the vlens in an array.

Usage

     int nc_free_vlens(size_t len, nc_vlen_t vlens[])
len
Length of the VLEN array to be freed.
vlens
Array of VLENs to be freed.

Return Codes

NC_NOERR
No error.