diff options
author | Bill Wendling <wendling@ncsa.uiuc.edu> | 2002-02-27 21:52:19 (GMT) |
---|---|---|
committer | Bill Wendling <wendling@ncsa.uiuc.edu> | 2002-02-27 21:52:19 (GMT) |
commit | 78e3463dbb62dcc18ebab71eaa7ec675aa9d3cae (patch) | |
tree | 7358d2e41412b3720cfbd96706010f84bbd85643 /tools/h5dump/h5dump.c | |
parent | f6ecbd18b046ddbb504b7365d8b5f1a9eeb0f9a4 (diff) | |
download | hdf5-78e3463dbb62dcc18ebab71eaa7ec675aa9d3cae.zip hdf5-78e3463dbb62dcc18ebab71eaa7ec675aa9d3cae.tar.gz hdf5-78e3463dbb62dcc18ebab71eaa7ec675aa9d3cae.tar.bz2 |
[svn-r5023] Purpose:
Bug Fix
Description:
There was a problem with having a lot of groups nested together. We
could only handle 1024 characters at most, but, in a parallel program
especially, it could occur that there were lots and lots of groups
and would be more than 1024.
Solution:
I made the "objname" part of the obj_t structure a pointer instead of
a fixed size. Added code to allocate/deallocate the memory we need
for it. Had to fix how the "prefix" was being handled in the h5dump
program. It was also set to only 1024 characters in length. I made it
dynamic.
Added a test case...Go me!
Platforms tested:
Linux, Solaris
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r-- | tools/h5dump/h5dump.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 767a604..ceb86d4 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1377,6 +1377,13 @@ dump_all(hid_t group, const char *name, void * op_data) d_status = EXIT_FAILURE; ret = FAIL; } else { + int new_len = strlen(prefix) + strlen(name) + 2; + + if (prefix_len <= new_len) { + prefix_len = new_len + 1; + prefix = realloc(prefix, prefix_len); + } + strcat(strcat(prefix, "/"), name); dump_function_table->dump_group_function(obj, name); strcpy(prefix, tmp); @@ -1448,7 +1455,8 @@ dump_all(hid_t group, const char *name, void * op_data) dset_table->objs[i].displayed = 1; strcat(tmp, "/"); strcat(tmp, name); - strcpy(dset_table->objs[i].objname, tmp); + free(dset_table->objs[i].objname); + dset_table->objs[i].objname = HDstrdup(tmp); } } @@ -1590,7 +1598,8 @@ dump_group(hid_t gid, const char *name) indentation(indent); printf("%s \"%s\"\n", HARDLINK, group_table->objs[i].objname); } else { - strcpy(group_table->objs[i].objname, prefix); + free(group_table->objs[i].objname); + group_table->objs[i].objname = HDstrdup(prefix); group_table->objs[i].displayed = 1; H5Aiterate(gid, NULL, dump_attr, NULL); H5Giterate(gid, ".", NULL, dump_all, (void *) &xtype); @@ -2193,7 +2202,8 @@ handle_datasets(hid_t fid, char *dset, void *data) end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); } else { - strcpy(dset_table->objs[idx].objname, dset); + free(dset_table->objs[idx].objname); + dset_table->objs[idx].objname = HDstrdup(dset); dset_table->objs[idx].displayed = 1; dump_dataset(dsetid, dset, sset); } @@ -2237,6 +2247,13 @@ handle_groups(hid_t fid, char *group, void * UNUSED data) dump_header_format->groupblockend); d_status = EXIT_FAILURE; } else { + int new_len = strlen(group) + 1; + + if (prefix_len <= new_len) { + prefix_len = new_len; + prefix = realloc(prefix, prefix_len); + } + H5Gget_objinfo(gid, ".", TRUE, &statbuf); strcpy(prefix, group); dump_group(gid, group); @@ -4342,7 +4359,8 @@ xml_dump_group(hid_t gid, const char *name) free(t_objname); } else { /* first time this group has been seen -- describe it */ - strcpy(group_table->objs[i].objname, prefix); + free(group_table->objs[i].objname); + group_table->objs[i].objname = HDstrdup(prefix); group_table->objs[i].displayed = 1; /* 1. do all the attributes of the group */ |