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 | |
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')
-rw-r--r-- | tools/h5dump/h5dump.c | 26 | ||||
-rw-r--r-- | tools/h5dump/h5dumptst.c | 22 | ||||
-rwxr-xr-x | tools/h5dump/testh5dump.sh | 3 |
3 files changed, 47 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 */ diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c index d26c4b8..0fb523b 100644 --- a/tools/h5dump/h5dumptst.c +++ b/tools/h5dump/h5dumptst.c @@ -55,6 +55,7 @@ #define FILE34 "tsplit_file" #define FILE35 "tfamily%05d.h5" #define FILE36 "tmulti" +#define FILE37 "tlarge_objname.h5" #define LENSTR 50 #define LENSTR2 11 @@ -2811,6 +2812,25 @@ void test_multi(void) H5Pclose(fapl); } +static void test_large_objname(void) +{ + hid_t fid, group; + char grp_name[128]; + register int i; + + fid = H5Fcreate(FILE37, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + group = H5Gcreate(fid, "this_is_a_large_group_name", 0); + + for (i = 0; i < 50; ++i) { + sprintf(grp_name, "this_is_a_large_group_name%d", i); + group = H5Gcreate(group, grp_name, 0); + } + + H5Gclose(group); + H5Fclose(fid); +} + int main(void) { test_group(); @@ -2860,5 +2880,7 @@ int main(void) test_family(); test_multi(); + test_large_objname(); + return 0; } diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh index 58f3a9c..83e71fc 100755 --- a/tools/h5dump/testh5dump.sh +++ b/tools/h5dump/testh5dump.sh @@ -155,6 +155,9 @@ TOOLTEST tsplit_file.ddl --filedriver=split tsplit_file TOOLTEST tfamily.ddl --filedriver=family tfamily%05d.h5 TOOLTEST tmulti.ddl --filedriver=multi tmulti +# test for files with group names which reach > 1024 bytes in size +TOOLTEST tlarge_objname.ddl -w157 tlarge_objname.h5 + # test Subsetting TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 |