diff options
Diffstat (limited to 'tools/lib/h5tools_str.c')
-rw-r--r-- | tools/lib/h5tools_str.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 0aa5152..c9e7e94 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1091,7 +1091,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai if (H5Tequal(type, H5T_STD_REF)) { H5O_type_t obj_type = -1; /* Object type */ H5R_type_t ref_type; /* Reference type */ - const H5R_ref_t *ref_vp = (const H5R_ref_t *)vp; + H5R_ref_t *ref_vp = (H5R_ref_t *)vp; H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF"); ref_type = H5Rget_type(ref_vp); @@ -1100,13 +1100,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai case H5R_OBJECT1: { /* Object references -- show the type and OID of the referenced object. */ - H5O_info_t oi; + H5O_info2_t oi; + char *obj_addr_str = NULL; H5TOOLS_DEBUG("ref_type is H5R_OBJECT1"); if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { - H5Oget_info2(obj, &oi, H5O_INFO_BASIC); - if(H5Oclose(obj) < 0) - H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed"); + H5Oget_info3(obj, &oi, H5O_INFO_BASIC); + H5Otoken_to_str(obj, &oi.token, &obj_addr_str); } else H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed"); @@ -1132,20 +1132,30 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_UNKNOWN); break; } /* end switch */ - H5Oclose(obj); - h5tools_str_sprint_reference(str, info, container, ref_vp); + + h5tools_str_sprint_reference(str, ref_vp); /* Print OID */ if(info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, oi.addr); + h5tools_str_append(str, info->obj_format, obj_addr_str); else - h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); + h5tools_str_append(str, info->obj_format, oi.fileno, obj_addr_str); + + if(obj_addr_str) { + H5free_memory(obj_addr_str); + obj_addr_str = NULL; } + + if(obj >= 0) + if(H5Oclose(obj) < 0) + H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed"); + } + break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); h5tools_str_append(str, H5_TOOLS_DATASET); - h5tools_str_sprint_reference(str, info, container, ref_vp); + h5tools_str_sprint_reference(str, ref_vp); break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); @@ -1169,17 +1179,17 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, H5_TOOLS_UNKNOWN); break; } /* end switch */ - h5tools_str_sprint_reference(str, info, container, ref_vp); + h5tools_str_sprint_reference(str, ref_vp); break; case H5R_DATASET_REGION2: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); h5tools_str_append(str, H5_TOOLS_DATASET); - h5tools_str_sprint_reference(str, info, container, ref_vp); + h5tools_str_sprint_reference(str, ref_vp); break; case H5R_ATTR: H5TOOLS_DEBUG("ref_type is H5R_ATTR"); h5tools_str_append(str, H5_TOOLS_ATTRIBUTE); - h5tools_str_sprint_reference(str, info, container, ref_vp); + h5tools_str_sprint_reference(str, ref_vp); break; case H5R_BADTYPE: case H5R_MAXTYPE: @@ -1334,7 +1344,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end switch */ } -done: ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); H5TOOLS_ENDDEBUG("exit with %s", ret_value); @@ -1351,8 +1360,7 @@ done: *------------------------------------------------------------------------- */ void -h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, - hid_t container, H5R_ref_t *ref_vp) +h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *ref_vp) { ssize_t buf_size; @@ -1363,7 +1371,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, H5TOOLS_DEBUG("buf_size=%ld", buf_size); if (buf_size) { char *file_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1); - if (H5Rget_file_name(ref_vp, file_name, buf_size + 1) >= 0) { + if (H5Rget_file_name(ref_vp, file_name, (size_t)buf_size + 1) >= 0) { file_name[buf_size] = '\0'; H5TOOLS_DEBUG("name=%s", file_name); h5tools_str_append(str, "%s", file_name); @@ -1375,7 +1383,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, H5TOOLS_DEBUG("buf_size=%ld", buf_size); if (buf_size) { char *obj_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1); - if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, buf_size + 1) >= 0) { + if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, (size_t)buf_size + 1) >= 0) { obj_name[buf_size] = '\0'; H5TOOLS_DEBUG("name=%s", obj_name); h5tools_str_append(str, "%s", obj_name); @@ -1388,7 +1396,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, H5TOOLS_DEBUG("buf_size=%ld", buf_size); if (buf_size) { char *attr_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1); - if (H5Rget_attr_name(ref_vp, attr_name, buf_size + 1) >= 0) { + if (H5Rget_attr_name(ref_vp, attr_name, (size_t)buf_size + 1) >= 0) { attr_name[buf_size] = '\0'; H5TOOLS_DEBUG("name=%s", attr_name); h5tools_str_append(str, "/%s", attr_name); |