diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools_ref.c | 14 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 2 |
2 files changed, 12 insertions, 4 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) { diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index e92f972..df103d7 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -435,7 +435,7 @@ find_objs(hid_t group, const char *name, void *op_data) switch (statbuf.type) { case H5G_GROUP: if ((obj = H5Gopen(group, name)) >= 0) { - if (info->prefix_len < (HDstrlen(info->prefix) + HDstrlen(name) + 2)) { + while (info->prefix_len < (HDstrlen(info->prefix) + HDstrlen(name) + 2)) { info->prefix_len *= 2; info->prefix = HDrealloc(info->prefix, info->prefix_len * sizeof(char)); |