diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2011-03-18 18:50:19 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2011-03-18 18:50:19 (GMT) |
commit | d697acbfb588b0406403109398105e12562e2d3e (patch) | |
tree | 8aa04d2c07a43ae2d75eea54938dc16318d444a0 /tools/lib/h5tools.c | |
parent | e038bf6eb718711c76a86074848e96a8158a12bd (diff) | |
download | hdf5-d697acbfb588b0406403109398105e12562e2d3e.zip hdf5-d697acbfb588b0406403109398105e12562e2d3e.tar.gz hdf5-d697acbfb588b0406403109398105e12562e2d3e.tar.bz2 |
[svn-r20270] Purpose:
Improve the previous fix for Bug 2216 - GMQS: h5diff - memory leak when
compares vlen string in dataset or attributes
Description:
Improve the fix along with the previous checkin r20266.
Add a new function to tool lib, h5tools_detect_vlen_data() which return
TRUE if include any kind of vlen data all at once, either VLEN-data or
VLEN-string and so on.
Also updated h5ls and h5dump code accordingly.
Tested:
jam (linux32-LE), amani (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Cmake - jam
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r-- | tools/lib/h5tools.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 1982bad..84a164b 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -622,6 +622,55 @@ h5tools_ncols(const char *s) } /*------------------------------------------------------------------------- + * Function: h5tools_detect_vlen_data + * + * Purpose: Recursive check for any variable length data in given type. + * + * Return: TRUE if type conatains any variable length data, else FALSE + * + * Programmer: Jonathan Kim March 18, 2011 + * + * Note: Adopted from h5tools_detect_vlen_str() which only check + * vlen-string data in type. + *------------------------------------------------------------------------- + */ +htri_t +h5tools_detect_vlen_data(hid_t tid) +{ + int i = 0; + int n = 0; + htri_t has_vlen_str = FALSE; + H5T_class_t tclass = -1; + + /* detect any vlen data in type */ + if (H5Tdetect_class(tid, H5T_VLEN) == TRUE || /* VLEN-data */ + H5Tis_variable_str(tid) == TRUE) /* VLEN-string*/ + return TRUE; + + tclass = H5Tget_class(tid); + if (tclass == H5T_ARRAY) { + hid_t btid = H5Tget_super(tid); + has_vlen_str = h5tools_detect_vlen_data(btid); + H5Tclose(btid); + return has_vlen_str; + } + else if (tclass == H5T_COMPOUND) { + n = H5Tget_nmembers(tid); + for (i = 0; i < n; i++) { + hid_t mtid = H5Tget_member_type(tid, i); + has_vlen_str = h5tools_detect_vlen_data(mtid); + if (has_vlen_str == TRUE) { + H5Tclose(mtid); + return TRUE; + } + H5Tclose(mtid); + } + } + return FALSE; +} + + +/*------------------------------------------------------------------------- * Function: h5tools_detect_vlen_str * * Purpose: Recursive check for variable length string of a datatype. |