diff options
Diffstat (limited to 'tools/lib/h5tools_ref.c')
-rw-r--r-- | tools/lib/h5tools_ref.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index b607d7d..fbcc734 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -36,7 +36,8 @@ extern hid_t thefile; -extern char *prefix; +size_t prefix_len = 1024; +char *prefix; extern char *progname; extern int d_status; @@ -227,17 +228,19 @@ fill_ref_path_table(hid_t group, const char *name, void UNUSED * op_data) { hid_t obj; char *tmp; + size_t tmp_len; H5G_stat_t statbuf; ref_path_table_entry_t *pte; char *thepath; H5Gget_objinfo(group, name, FALSE, &statbuf); - tmp = (char *) malloc(strlen(prefix) + strlen(name) + 2); + tmp_len = strlen(prefix) + strlen(name) + 2; + tmp = (char *) malloc(tmp_len); if (tmp == NULL) return FAIL; - thepath = (char *) malloc(strlen(prefix) + strlen(name) + 2); + thepath = (char *) malloc(tmp_len); if (thepath == NULL) { free(tmp); @@ -264,6 +267,11 @@ fill_ref_path_table(hid_t group, const char *name, void UNUSED * op_data) break; case H5G_GROUP: if ((obj = H5Gopen(group, name)) >= 0) { + if (prefix_len <= tmp_len) { + prefix_len = tmp_len + 1; + prefix = realloc(prefix, prefix_len); + } + strcat(strcat(prefix, "/"), name); pte = ref_path_table_lookup(thepath); if (pte == NULL) { |