diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff_attr.c | 12 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 5 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 49 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 1 |
4 files changed, 55 insertions, 12 deletions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 1742028..01fa896 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -223,14 +223,12 @@ hsize_t diff_attr(hid_t loc1_id, /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any * VLEN memory first */ - if(TRUE == H5Tdetect_class(mtype1_id, H5T_VLEN) || - TRUE == h5tools_detect_vlen_str(mtype1_id)) + if(TRUE == h5tools_detect_vlen_data(mtype1_id)) H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); buf1 = NULL; - if(TRUE == H5Tdetect_class(mtype2_id, H5T_VLEN) || - TRUE == h5tools_detect_vlen_str(mtype2_id)) + if(TRUE == h5tools_detect_vlen_data(mtype2_id)) H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); buf2 = NULL; @@ -260,14 +258,12 @@ hsize_t diff_attr(hid_t loc1_id, error: H5E_BEGIN_TRY { if(buf1) { - if(TRUE == H5Tdetect_class(mtype1_id, H5T_VLEN) || - TRUE == h5tools_detect_vlen_str(mtype1_id)) + if(TRUE == h5tools_detect_vlen_data(mtype1_id)) H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); HDfree(buf1); } /* end if */ if(buf2) { - if(TRUE == H5Tdetect_class(mtype2_id, H5T_VLEN) || - TRUE == h5tools_detect_vlen_str(mtype2_id)) + if(TRUE == h5tools_detect_vlen_data(mtype2_id)) H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); HDfree(buf2); } /* end if */ diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index b21230b..b1193c6 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -330,11 +330,8 @@ hsize_t diff_datasetid( hid_t did1, /* Check if type is either VLEN-data or VLEN-string to reclaim any * VLEN memory buffer later */ - if(TRUE == H5Tdetect_class(m_tid1, H5T_VLEN) || - TRUE == h5tools_detect_vlen_str(m_tid1)) - { + if( TRUE == h5tools_detect_vlen_data(m_tid1) ) vl_data = TRUE; - } /*------------------------------------------------------------------------- * only attempt to compare if possible 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. diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 6d054b8..376f05a 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -553,6 +553,7 @@ H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type); H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type); H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type); +H5TOOLS_DLL htri_t h5tools_detect_vlen_data(hid_t tid); H5TOOLS_DLL htri_t h5tools_detect_vlen_str(hid_t tid); H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, |