diff options
author | Mike McGreevy <mamcgree@hdfgroup.org> | 2010-05-14 18:45:07 (GMT) |
---|---|---|
committer | Mike McGreevy <mamcgree@hdfgroup.org> | 2010-05-14 18:45:07 (GMT) |
commit | 453a3910ab7942daa7b01e821e15853cb7a0ba23 (patch) | |
tree | 04ef561bcd6f37bd07c1fea794cdbcfdc92bcd15 /src/H5Tvlen.c | |
parent | fbb8709e40c97724dbb6ab137b9fb480a59e4fa5 (diff) | |
download | hdf5-453a3910ab7942daa7b01e821e15853cb7a0ba23.zip hdf5-453a3910ab7942daa7b01e821e15853cb7a0ba23.tar.gz hdf5-453a3910ab7942daa7b01e821e15853cb7a0ba23.tar.bz2 |
[svn-r18805] Purpose:
Fix memory leaks
Description
Added a routine to free memory which addresses a memory leak
when variable length strings are used as fill values.
Also added some minor tweaks to the H5I 'save ID structures' mechanic.
Tested:
h5committest and valgrind (on jam/amani) to confirm freed memory.
Diffstat (limited to 'src/H5Tvlen.c')
-rw-r--r-- | src/H5Tvlen.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 8a6ee05..95f4086 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -1303,3 +1303,44 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_vlen_get_alloc_info() */ + +/*------------------------------------------------------------------------- + * Function: H5T_vlen_reclaim_elmt + * + * Purpose: Alternative method to reclaim any VL data for a buffer element. + * + * Use this function when the datatype is already available, but + * the allocation info is needed from the dxpl_id before jumping + * into recursion. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mike McGreevy + * May 11, 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt, hid_t dxpl_id) +{ + H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ + H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ + herr_t ret_value = SUCCEED; /* return value */ + + HDassert(dt); + HDassert(elem); + + FUNC_ENTER_NOAPI(H5T_vlen_reclaim_elmt, FAIL) + + /* Get VL allocation info */ + if (H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") + + /* Recurse on buffer to free dynamic fields */ + ret_value = H5T_vlen_reclaim_recurse(elem,dt,vl_alloc_info->free_func,vl_alloc_info->free_info); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5T_vlen_reclaim_elmt */ |