Last modified: 23 April 2014

Name: H5free_memory

Signature:
herr_t H5free_memory(void *buf)

Purpose:
Frees memory allocated by the HDF5 Library.

Description:
In order to avoid heap corruption, allocated memory should be freed using the same library that initially allocated it. In most cases, the HDF5 API uses resources that are allocated and freed entirely by either the user or the library. In some cases, however, HDF5 API calls will allocate memory that the user must free (for example, H5Tget_member_name). H5free_memory allows the user to safely free this memory.

Notes:
It is especially important to use this function to free memory allocated by the library on Windows. The C standard library is implemented in dynamic link libraries (DLLs) known as the C run-time (CRT). Each version of Visual Studio comes with two CRT DLLs (debug and release) and allocating and freeing across DLL boundaries can cause resource leaks and subtle bugs due to heap corruption.

Only use this function to free memory allocated by the HDF5 Library. It will generally not be safe to use this function to free memory allocated by any other means.

Even when using this function, it is still best to ensure that all components of a C application are built with the same version of Visual Studio and build (debug or release) and thus linked against the same CRT.


Parameters:
void *mem IN: Buffer to be freed. Can be NULL.

Returns:
Returns a non-negative value if successful. Otherwise returns a negative value.

Fortran Interface:
None

See Also:

History:
Release Change
1.8.13 C function introduced with this release.