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/h5dump | |
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/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index bebc892..cf02a47 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2545,11 +2545,18 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) char string_prefix[64]; h5tool_format_t string_dataformat; + /* VL data special information */ + unsigned int vl_data = 0; /* contains VL datatypes */ + type = H5Aget_type(obj_id); p_type = h5tools_get_native_type(type); ndims = H5Sget_simple_extent_dims(space, size, NULL); + /* Check if we have VL data in the dataset's datatype */ + if (H5Tdetect_vlen_str(p_type) == TRUE) + vl_data = TRUE; + for (i = 0; i < ndims; i++) nelmts *= size[i]; @@ -2590,6 +2597,10 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index) status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); + free(buf); H5Tclose(p_type); H5Tclose(type); @@ -5502,10 +5513,16 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU H5Tclose(type); } else if (H5Tget_class(type) == H5T_STRING) { status = xml_print_strs(obj_id, ATTRIBUTE_DATA); - } else { - /* all other data */ + } else { /* all other data */ + /* VL data special information */ + unsigned int vl_data = 0; /* contains VL datatypes */ + p_type = h5tools_get_native_type(type); + /* Check if we have VL data in the dataset's datatype */ + if (H5Tdetect_vlen_str(p_type) == TRUE) + vl_data = TRUE; + H5Tclose(type); space = H5Aget_space(obj_id); @@ -5522,6 +5539,10 @@ xml_dump_data(hid_t obj_id, int obj_data, struct subset_t UNUSED * sset, int UNU status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); + /* Reclaim any VL memory, if necessary */ + if (vl_data) + H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); + free(buf); H5Tclose(p_type); H5Sclose(space); |