summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack/h5repack.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/h5repack/h5repack.c')
-rw-r--r--tools/src/h5repack/h5repack.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 6f0e4eb..8eeaa0e 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -222,18 +222,27 @@ h5repack_addlayout(const char *str, pack_opt_t *options)
hid_t
copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options)
{
- named_dt_t *dt = *named_dt_head_p; /* Stack pointer */
- named_dt_t *dt_ret = NULL; /* Datatype to return */
- H5O_info_t oinfo; /* Object info of input dtype */
- hid_t ret_value = H5I_INVALID_HID;
+ named_dt_t *dt = *named_dt_head_p; /* Stack pointer */
+ named_dt_t *dt_ret = NULL; /* Datatype to return */
+ H5O_info2_t oinfo; /* Object info of input dtype */
+ int token_cmp;
+ hid_t ret_value = H5I_INVALID_HID;
- if (H5Oget_info2(type_in, &oinfo, H5O_INFO_BASIC) < 0)
+ if (H5Oget_info3(type_in, &oinfo, H5O_INFO_BASIC) < 0)
H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed");
if (*named_dt_head_p) {
+ if (H5Otoken_cmp(type_in, &dt->obj_token, &oinfo.token, &token_cmp) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to compare object tokens");
+
/* Stack already exists, search for the datatype */
- while (dt && dt->addr_in != oinfo.addr)
+ while (dt && token_cmp) {
dt = dt->next;
+
+ if (H5Otoken_cmp(type_in, &dt->obj_token, &oinfo.token, &token_cmp) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to compare object tokens");
+ }
+
dt_ret = dt;
}
else {
@@ -249,13 +258,14 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
*named_dt_head_p = dt;
/* Update the address and id */
- dt->addr_in = travt->objs[i].objno;
- dt->id_out = -1;
+ HDmemcpy(&dt->obj_token, &travt->objs[i].obj_token, sizeof(H5O_token_t));
+ dt->id_out = H5I_INVALID_HID;
/* Check if this type is the one requested */
- if (oinfo.addr == dt->addr_in) {
+ if (H5Otoken_cmp(type_in, &oinfo.token, &dt->obj_token, &token_cmp) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to compare object tokens");
+ if (!token_cmp)
dt_ret = dt;
- }
} /* end if named datatype */
} /* end for each object in traversal table */
} /* end else (create the stack) */
@@ -271,8 +281,8 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
*named_dt_head_p = dt_ret;
/* Update the address and id */
- dt_ret->addr_in = oinfo.addr;
- dt_ret->id_out = -1;
+ HDmemcpy(&dt_ret->obj_token, &oinfo.token, sizeof(H5O_token_t));
+ dt_ret->id_out = H5I_INVALID_HID;
} /* end if requested datatype not found */
/* If the requested datatype does not yet exist in the output file, copy it
@@ -343,11 +353,11 @@ done:
int
copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options)
{
- hid_t attr_id = -1; /* attr ID */
- hid_t attr_out = -1; /* attr ID */
- hid_t space_id = -1; /* space ID */
- hid_t ftype_id = -1; /* file type ID */
- hid_t wtype_id = -1; /* read/write type ID */
+ hid_t attr_id = H5I_INVALID_HID; /* attr ID */
+ hid_t attr_out = H5I_INVALID_HID; /* attr ID */
+ hid_t space_id = H5I_INVALID_HID; /* space ID */
+ hid_t ftype_id = H5I_INVALID_HID; /* file type ID */
+ hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */
size_t msize; /* size of type */
void *buf = NULL; /* data buffer */
hsize_t nelmts; /* number of elements in dataset */
@@ -355,14 +365,14 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
htri_t is_named; /* Whether the datatype is named */
hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */
char name[255];
- H5O_info_t oinfo; /* object info */
+ H5O_info2_t oinfo; /* object info */
int j;
unsigned u;
hbool_t is_ref = 0;
H5T_class_t type_class = -1;
int ret_value = 0;
- if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
+ if (H5Oget_info3(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed");
/*-------------------------------------------------------------------------
@@ -385,7 +395,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
if ((is_named = H5Tcommitted(ftype_id)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed");
if (is_named && travt) {
- hid_t fidout = -1;
+ hid_t fidout = H5I_INVALID_HID;
/* Create out file id */
if ((fidout = H5Iget_file_id(loc_out)) < 0)
@@ -432,7 +442,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
type_class = H5Tget_class(wtype_id);
is_ref = (type_class == H5T_REFERENCE);
if (type_class == H5T_VLEN || type_class == H5T_ARRAY) {
- hid_t base_type = -1;
+ hid_t base_type = H5I_INVALID_HID;
base_type = H5Tget_super(ftype_id);
is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE));
@@ -500,16 +510,16 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_
*/
if (H5Sclose(space_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed");
- space_id = -1;
+ space_id = H5I_INVALID_HID;
if (H5Tclose(wtype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- wtype_id = -1;
+ wtype_id = H5I_INVALID_HID;
if (H5Tclose(ftype_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed");
- ftype_id = -1;
+ ftype_id = H5I_INVALID_HID;
if (H5Aclose(attr_id) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed");
- attr_id = -1;
+ attr_id = H5I_INVALID_HID;
} /* for u (each attribute) */
done:
@@ -725,9 +735,9 @@ done:
static int
check_objects(const char* fname, pack_opt_t *options)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t sid = -1;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
unsigned int i;
int ifil;
trav_table_t *travt = NULL;
@@ -752,7 +762,7 @@ check_objects(const char* fname, pack_opt_t *options)
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
- trav_table_init(&travt);
+ trav_table_init(fid, &travt);
/* get the list of objects in the file */
if (h5trav_gettable(fid, travt) < 0)