diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2011-03-09 20:00:20 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2011-03-09 20:00:20 (GMT) |
commit | 5b3223c7c569a3a20103c36ea8b38ae744033d2b (patch) | |
tree | 09ae2b7745a4c963c389fca86b3e3a4ae1f1d3ab /tools/h5ls/h5ls.c | |
parent | 2a492f23a1bfc25169dc6f063afaf6dd20d0e749 (diff) | |
download | hdf5-5b3223c7c569a3a20103c36ea8b38ae744033d2b.zip hdf5-5b3223c7c569a3a20103c36ea8b38ae744033d2b.tar.gz hdf5-5b3223c7c569a3a20103c36ea8b38ae744033d2b.tar.bz2 |
[svn-r20216] Valgrind fix for memory leak in h5tools_dump_xxx which is fixed by adding a new function;
htri_t H5Tdetect_vlen_str(hid_t tid) to h5tools. This needs to be called before any H5Aread/H5Dread and if TRUE, then call vlen_reclaim function after the corresponding h5tools_dump_xxx().
Tested: local linux and valgrind
Diffstat (limited to 'tools/h5ls/h5ls.c')
-rw-r--r-- | tools/h5ls/h5ls.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 420ff3f..d2233ce 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -1449,6 +1449,13 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, p_type = h5tools_get_native_type(type); if(p_type >= 0) { + /* VL data special information */ + unsigned int vl_data = 0; /* contains VL datatypes */ + + /* Check if we have VL data in the dataset's datatype */ + if (H5Tdetect_vlen_str(p_type) == TRUE) + vl_data = TRUE; + temp_need= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); assert(temp_need == (hsize_t)((size_t)temp_need)); need = (size_t)temp_need; @@ -1456,6 +1463,11 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo, assert(buf); if(H5Aread(attr, p_type, buf) >= 0) h5tools_dump_mem(stdout, &info, attr, p_type, space, buf, -1); + + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); + free(buf); H5Tclose(p_type); } /* end if */ |