summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2011-03-14 21:05:44 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2011-03-14 21:05:44 (GMT)
commita518bae9c0120f4e4dd8e72c1c4de17e699e498d (patch)
treed0061a0198296eb773f837a9e44fe1789f297671 /tools
parent6d8bfb439cbb27b25dcdcb6b4fcffc38837e142e (diff)
downloadhdf5-a518bae9c0120f4e4dd8e72c1c4de17e699e498d.zip
hdf5-a518bae9c0120f4e4dd8e72c1c4de17e699e498d.tar.gz
hdf5-a518bae9c0120f4e4dd8e72c1c4de17e699e498d.tar.bz2
[svn-r20248] Change name of new VLEN function from H5Tdetect_vlen_str to h5tools_detect_vlen_str to match other functions in tools lib.
Added back test for H5Tdetect_class of H5T_VLEN after each instance of above function to catch all VLEN types in h5dump. bring back from trunk r20247 Tested: local linux
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c45
-rw-r--r--tools/h5ls/h5ls.c14
-rw-r--r--tools/lib/h5tools.c59
-rw-r--r--tools/lib/h5tools.h1
4 files changed, 112 insertions, 7 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 9f5cf0c..2581f33 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -867,8 +867,11 @@ table_list_free(void)
/* Free each table */
free_table(table_list.tables[u].group_table);
+ HDfree(table_list.tables[u].group_table);
free_table(table_list.tables[u].dset_table);
+ HDfree(table_list.tables[u].dset_table);
free_table(table_list.tables[u].type_table);
+ HDfree(table_list.tables[u].type_table);
}
/* Free the table list */
@@ -1204,7 +1207,9 @@ print_datatype(hid_t type,unsigned in_group)
indentation(indent + COL);
printf("H5T_OPAQUE;\n");
indentation(indent + COL);
- printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type));
+ mname = H5Tget_tag(type);
+ printf("OPAQUE_TAG \"%s\";\n", mname);
+ free(mname);
indentation(indent);
break;
@@ -1503,8 +1508,11 @@ dump_selected_attr(hid_t loc_id, const char *name)
obj_name = (char *)HDmalloc((size_t)j + 2);
/* find the last / */
- while(name[j] != '/' && j >= 0)
+ while(j >= 0) {
+ if (name[j] == '/')
+ break;
j--;
+ }
/* object name */
if(j == -1)
@@ -2601,11 +2609,20 @@ 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 (h5tools_detect_vlen_str(p_type) == TRUE)
+ vl_data = TRUE;
+ if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
for (i = 0; i < ndims; i++)
nelmts *= size[i];
@@ -2646,6 +2663,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);
@@ -2772,8 +2793,7 @@ dump_comment(hid_t obj_id)
cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
- /* if the actual length of the comment is longer than cmt_bufsize, then call
- * H5Oget_comment again with the correct value.
+ /* call H5Oget_comment again with the correct value.
* If the call to H5Oget_comment returned an error, skip this block */
if (cmt_bufsize > 0) {
comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */
@@ -4711,6 +4731,7 @@ main(int argc, const char *argv[])
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xsi:schemaLocation=\"http://hdfgroup.org/DTDs/HDF5-File "
"http://www.hdfgroup.org/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ HDfree(ns);
}
} else {
printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
@@ -5731,10 +5752,18 @@ 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 (h5tools_detect_vlen_str(p_type) == TRUE)
+ vl_data = TRUE;
+ if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
H5Tclose(type);
space = H5Aget_space(obj_id);
@@ -5751,6 +5780,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);
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 5671700..d288f4b 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -1453,6 +1453,15 @@ 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 (h5tools_detect_vlen_str(p_type) == TRUE)
+ vl_data = TRUE;
+ if (H5Tdetect_class(p_type, H5T_VLEN) == 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;
@@ -1460,6 +1469,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 */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index ec48410..9790865 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -627,6 +627,48 @@ h5tools_ncols(const char *s)
}
/*-------------------------------------------------------------------------
+ * Function: h5tools_detect_vlen_str
+ *
+ * Purpose: Recursive check for variable length string of a datatype.
+ *
+ * Return: TRUE if type conatains a variable string type, else FALSE
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+h5tools_detect_vlen_str(hid_t tid)
+{
+ int i = 0;
+ int n = 0;
+ htri_t has_vlen_str = FALSE;
+ H5T_class_t tclass = -1;
+
+ if (H5Tis_variable_str(tid) == TRUE)
+ return TRUE;
+
+ tclass = H5Tget_class(tid);
+ if (tclass == H5T_ARRAY) {
+ hid_t btid = H5Tget_super(tid);
+ has_vlen_str = h5tools_detect_vlen_str(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_str(mtid);
+ if (has_vlen_str == TRUE) {
+ H5Tclose(mtid);
+ return TRUE;
+ }
+ H5Tclose(mtid);
+ }
+ }
+ return FALSE;
+}
+
+/*-------------------------------------------------------------------------
* Audience: Public
* Chapter: H5Tools Library
* Purpose: Emit a simple prefix to STREAM.
@@ -1981,6 +2023,9 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
hsize_t size_row_block; /* size for blocks along rows */
hsize_t row_counter = 0;
+ /* VL data special information */
+ unsigned int vl_data = 0; /* contains VL datatypes */
+
if ((size_t) ctx->ndims > NELMTS(sm_size))
H5E_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed");
@@ -1989,6 +2034,12 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
size_row_block = sset->block.data[row_dim];
+ /* Check if we have VL data in the dataset's datatype */
+ if (h5tools_detect_vlen_str(p_type) == TRUE)
+ vl_data = TRUE;
+ if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
+ vl_data = TRUE;
+
/* display loop */
for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) {
/* jump rows if size of block exceeded
@@ -2072,6 +2123,10 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c
h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf);
+ /* Reclaim any VL memory, if necessary */
+ if (vl_data)
+ H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf);
+
if(H5Sclose(sm_space) < 0)
H5E_THROW(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
if(sm_buf)
@@ -2420,9 +2475,11 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
}
/* Check if we have VL data in the dataset's datatype */
+ if (h5tools_detect_vlen_str(p_type) == TRUE)
+ vl_data = TRUE;
if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
vl_data = TRUE;
-
+
/*
* Determine the strip mine size and allocate a buffer. The strip mine is
* a hyperslab whose size is manageable.
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 740dd38..66d5167 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -559,6 +559,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_str(hid_t tid);
H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,