[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
This commit is contained in:
Bill Wendling 2002-02-27 16:52:19 -05:00
parent f6ecbd18b0
commit 78e3463dbb
7 changed files with 163 additions and 7 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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

View File

@ -318,6 +318,7 @@ init_table(table_t **tbl)
table->objs[i].displayed = 0;
table->objs[i].recorded = 0;
table->objs[i].objflag = 0;
table->objs[i].objname = NULL;
}
*tbl = table;
@ -495,7 +496,8 @@ find_objs(hid_t group, const char *name, void *op_data)
/* named data type */
info->type_table->objs[info->type_table->nobjs-1].objflag = 1;
} else {
strcpy (info->type_table->objs[i].objname, tmp);
free(info->type_table->objs[i].objname);
info->type_table->objs[i].objname = HDstrdup(tmp);
info->type_table->objs[i].recorded = 1;
/* named data type */
@ -649,11 +651,13 @@ add_obj(table_t *table, unsigned long *objno, char *objname)
table->objs[i].displayed = 0;
table->objs[i].recorded = 0;
table->objs[i].objflag = 0;
table->objs[i].objname = NULL;
}
}
i = table->nobjs++;
table->objs[i].objno[0] = objno[0];
table->objs[i].objno[1] = objno[1];
HDstrcpy(table->objs[i].objname, objname);
free(table->objs[i].objname);
table->objs[i].objname = HDstrdup(objname);
}

View File

@ -69,7 +69,7 @@ extern int get_option(int argc, const char **argv, const char *opt,
/*struct taken from the dumper. needed in table struct*/
typedef struct obj_t {
unsigned long objno[2];
char objname[1024];
char *objname;
int displayed;
int recorded;
int objflag;

View File

@ -0,0 +1,109 @@
#############################
Expected output for 'h5dump -w157 tlarge_objname.h5'
#############################
HDF5 "tlarge_objname.h5" {
GROUP "/" {
GROUP "this_is_a_large_group_name" {
GROUP "this_is_a_large_group_name0" {
GROUP "this_is_a_large_group_name1" {
GROUP "this_is_a_large_group_name2" {
GROUP "this_is_a_large_group_name3" {
GROUP "this_is_a_large_group_name4" {
GROUP "this_is_a_large_group_name5" {
GROUP "this_is_a_large_group_name6" {
GROUP "this_is_a_large_group_name7" {
GROUP "this_is_a_large_group_name8" {
GROUP "this_is_a_large_group_name9" {
GROUP "this_is_a_large_group_name10" {
GROUP "this_is_a_large_group_name11" {
GROUP "this_is_a_large_group_name12" {
GROUP "this_is_a_large_group_name13" {
GROUP "this_is_a_large_group_name14" {
GROUP "this_is_a_large_group_name15" {
GROUP "this_is_a_large_group_name16" {
GROUP "this_is_a_large_group_name17" {
GROUP "this_is_a_large_group_name18" {
GROUP "this_is_a_large_group_name19" {
GROUP "this_is_a_large_group_name20" {
GROUP "this_is_a_large_group_name21" {
GROUP "this_is_a_large_group_name22" {
GROUP "this_is_a_large_group_name23" {
GROUP "this_is_a_large_group_name24" {
GROUP "this_is_a_large_group_name25" {
GROUP "this_is_a_large_group_name26" {
GROUP "this_is_a_large_group_name27" {
GROUP "this_is_a_large_group_name28" {
GROUP "this_is_a_large_group_name29" {
GROUP "this_is_a_large_group_name30" {
GROUP "this_is_a_large_group_name31" {
GROUP "this_is_a_large_group_name32" {
GROUP "this_is_a_large_group_name33" {
GROUP "this_is_a_large_group_name34" {
GROUP "this_is_a_large_group_name35" {
GROUP "this_is_a_large_group_name36" {
GROUP "this_is_a_large_group_name37" {
GROUP "this_is_a_large_group_name38" {
GROUP "this_is_a_large_group_name39" {
GROUP "this_is_a_large_group_name40" {
GROUP "this_is_a_large_group_name41" {
GROUP "this_is_a_large_group_name42" {
GROUP "this_is_a_large_group_name43" {
GROUP "this_is_a_large_group_name44" {
GROUP "this_is_a_large_group_name45" {
GROUP "this_is_a_large_group_name46" {
GROUP "this_is_a_large_group_name47" {
GROUP "this_is_a_large_group_name48" {
GROUP "this_is_a_large_group_name49" {
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

Binary file not shown.