diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2018-09-24 19:23:41 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2018-09-24 19:23:41 (GMT) |
commit | a56b4db4ae25d30e6e7eb96f27d7b91e35148591 (patch) | |
tree | 7738d08a9734103fd12242eb5ff0244dd74c214d /src/H5Oint.c | |
parent | 37309c1bd98b3d810f09569c72ac375e75117a91 (diff) | |
download | hdf5-a56b4db4ae25d30e6e7eb96f27d7b91e35148591.zip hdf5-a56b4db4ae25d30e6e7eb96f27d7b91e35148591.tar.gz hdf5-a56b4db4ae25d30e6e7eb96f27d7b91e35148591.tar.bz2 |
Remainder of vol_normalization changes (dataset, attribute, files, objects).
Diffstat (limited to 'src/H5Oint.c')
-rw-r--r-- | src/H5Oint.c | 166 |
1 files changed, 82 insertions, 84 deletions
diff --git a/src/H5Oint.c b/src/H5Oint.c index 49d7835..44809e1 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -42,7 +42,6 @@ #include "H5MMprivate.h" /* Memory management */ #endif /* H5O_ENABLE_BOGUS */ #include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ /****************/ @@ -514,12 +513,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_open_name + * Function: H5O_open_name * - * Purpose: Opens an object within an HDF5 file. + * Purpose: Opens an object within an HDF5 file. * - * Return: Success: An open object identifier - * Failure: Negative + * Return: Success: Open object identifier + * Failure: H5I_INVALID_HID * * Programmer: Quincey Koziol * March 5 2007 @@ -552,7 +551,7 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref) loc_found = TRUE; /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, app_ref)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, app_ref)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: @@ -565,12 +564,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5O__open_by_idx + * Function: H5O_open_by_idx * * Purpose: Internal routine to open an object by index within group * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Open object identifier + * Failure: H5I_INVALID_HID * * Programmer: Quincey Koziol * December 28, 2017 @@ -578,7 +577,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, +H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5G_loc_t obj_loc; /* Location used to open group */ @@ -587,7 +586,7 @@ H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, hbool_t loc_found = FALSE; /* Entry at 'name' found */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check arguments */ HDassert(loc); @@ -603,7 +602,7 @@ H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, loc_found = TRUE; /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: @@ -613,16 +612,16 @@ done: HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__open_by_idx() */ +} /* end H5O_open_by_idx() */ /*------------------------------------------------------------------------- - * Function: H5O__open_by_addr + * Function: H5O_open_by_addr * * Purpose: Internal routine to open an object by its address * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Open object identifier + * Failure: H5I_INVALID_HID * * Programmer: Quincey Koziol * December 28, 2017 @@ -630,14 +629,14 @@ done: *------------------------------------------------------------------------- */ hid_t -H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr) +H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check arguments */ HDassert(loc); @@ -651,21 +650,21 @@ H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr) H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ /* Open the object */ - if((ret_value = H5O__open_by_loc(&obj_loc, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__open_by_addr() */ +} /* end H5O_open_by_addr() */ /*------------------------------------------------------------------------- - * Function: H5O__open_by_loc + * Function: H5O_open_by_loc * - * Purpose: Opens an object and returns an ID given its group loction. + * Purpose: Opens an object and returns an ID given its group loction. * - * Return: Success: Open object identifier - * Failure: Negative + * Return: Success: Open object identifier + * Failure: H5I_INVALID_HID * * Programmer: James Laird * July 25 2006 @@ -673,12 +672,12 @@ done: *------------------------------------------------------------------------- */ hid_t -H5O__open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) +H5O_open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) { const H5O_obj_class_t *obj_class; /* Class of object for location */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_NOAPI(H5I_INVALID_HID) HDassert(obj_loc); @@ -693,7 +692,7 @@ H5O__open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__open_by_loc() */ +} /* end H5O_open_by_loc() */ /*------------------------------------------------------------------------- @@ -735,10 +734,9 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) #ifdef H5O_DEBUG if(H5DEBUG(O)) { if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) - HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", - loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); - else - HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); + HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); + else + HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); } #endif @@ -761,14 +759,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5O__link_oh + * Function: H5O__link_oh * - * Purpose: Adjust the link count for an open object header by adding - * ADJUST to the link count. + * Purpose: Adjust the link count for an open object header by adding + * ADJUST to the link count. * - * Return: Success: New link count + * Return: Success: New link count * - * Failure: Negative + * Failure: -1 * * Programmer: Robb Matzke * matzke@llnl.gov @@ -794,14 +792,14 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) if(adjust < 0) { /* Check for too large of an adjustment */ if((unsigned)(-adjust) > oh->nlink) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative") + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, (-1), "link count would be negative") /* Adjust the link count for the object header */ oh->nlink = (unsigned)((int)oh->nlink + adjust); /* Mark object header as dirty in cache */ if(H5AC_mark_entry_dirty(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") + HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") /* Check if the object should be deleted */ if(oh->nlink == 0) { @@ -809,7 +807,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) if(H5FO_opened(f, addr) != NULL) { /* Flag the object to be deleted when it's closed */ if(H5FO_mark(f, addr, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ else { /* Mark the object header for deletion */ @@ -824,7 +822,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) if(H5FO_marked(f, addr)) { /* Remove "delete me" flag on the object */ if(H5FO_mark(f, addr, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "can't mark object for deletion") } /* end if */ } /* end if */ @@ -833,7 +831,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) /* Mark object header as dirty in cache */ if(H5AC_mark_entry_dirty(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") + HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, (-1), "unable to mark object header as dirty") } /* end if */ /* Check for operations on refcount message */ @@ -843,7 +841,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) /* Check for removing refcount message */ if(oh->nlink <= 1) { if(H5O__msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete refcount message") + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, (-1), "unable to delete refcount message") oh->has_refcount_msg = FALSE; } /* end if */ /* Update refcount message with new link count */ @@ -851,7 +849,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) H5O_refcount_t refcount = oh->nlink; if(H5O__msg_write_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update refcount message") + HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, (-1), "unable to update refcount message") } /* end else */ } /* end if */ else { @@ -860,7 +858,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) H5O_refcount_t refcount = oh->nlink; if(H5O__msg_append_real(f, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to create new refcount message") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, (-1), "unable to create new refcount message") oh->has_refcount_msg = TRUE; } /* end if */ } /* end else */ @@ -1061,7 +1059,7 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) } /* end if */ #ifdef H5O_DEBUG -H5O_assert(oh); +H5O__assert(oh); #endif /* H5O_DEBUG */ /* Pin the other chunks also when requested, so that the object header @@ -1325,8 +1323,9 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) chk_dirtied = TRUE; } /* end if */ else { - /* XXX: For now, update access time & change fields in the object header */ - /* (will need to add some code to update modification time appropriately) */ + /* XXX: For now, update access time & change fields in the object header + * (will need to add some code to update modification time appropriately) + */ oh->atime = oh->ctime = now; /* Mark object header as dirty in cache */ @@ -1426,25 +1425,25 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) H5O_bogus_t *bogus; /* Pointer to the bogus information */ /* Allocate the native message in memory */ - if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") + if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") /* Update the native value */ bogus->u = H5O_BOGUS_VALUE; - if(bogus_id == H5O_BOGUS_VALID_ID) - type = H5O_MSG_BOGUS_VALID; - else if(bogus_id == H5O_BOGUS_INVALID_ID) - type = H5O_MSG_BOGUS_INVALID; - else - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") + if(bogus_id == H5O_BOGUS_VALID_ID) + type = H5O_MSG_BOGUS_VALID; + else if(bogus_id == H5O_BOGUS_INVALID_ID) + type = H5O_MSG_BOGUS_INVALID; + else + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") /* Allocate space in the object header for bogus message */ - if(H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") + if(H5O__msg_alloc(f, oh, type, &mesg_flags, bogus, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ - oh->mesg[idx].native = bogus; + oh->mesg[idx].native = bogus; /* Set the appropriate flags for the message */ oh->mesg[idx].flags = mesg_flags; @@ -1634,23 +1633,23 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) /* Set type to "unknown" */ *obj_type = H5O_TYPE_UNKNOWN; - } /* end if */ + } else { /* Set object type */ *obj_type = obj_class->type; - } /* end else */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__obj_type_real() */ /*------------------------------------------------------------------------- - * Function: H5O__obj_class + * Function: H5O__obj_class * - * Purpose: Returns the class of object pointed to by `loc'. + * Purpose: Returns the class of object pointed to by 'loc'. * - * Return: Success: An object class - * Failure: NULL + * Return: Success: An object class + * Failure: NULL * * Programmer: Quincey Koziol * Monday, November 6, 2006 @@ -1663,7 +1662,7 @@ H5O__obj_class(const H5O_loc_t *loc) H5O_t *oh = NULL; /* Object header for location */ const H5O_obj_class_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_STATIC_TAG(loc->addr) + FUNC_ENTER_PACKAGE_TAG(loc->addr) /* Load the object header */ if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE))) @@ -1675,7 +1674,7 @@ H5O__obj_class(const H5O_loc_t *loc) done: if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O__obj_class() */ @@ -1714,7 +1713,7 @@ H5O__obj_class_real(const H5O_t *oh) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") else if(isa) HGOTO_DONE(H5O_obj_class_g[i - 1]) - } /* end for */ + } if(0 == i) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") @@ -2164,7 +2163,7 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) /* Retrieve # of attributes */ if(fields & H5O_INFO_NUM_ATTRS) - if(H5O_attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) + if(H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") /* Get B-tree & heap metadata storage size, if requested */ @@ -2580,7 +2579,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5O__visit + * Function: H5O__visit * * Purpose: Recursively visit an object and all the objects reachable * from it. If the starting object is a group, all the objects @@ -2601,12 +2600,12 @@ done: * Note: Add a parameter "fields" to indicate selection of object info. * * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * * Programmer: Quincey Koziol * November 24 2007 @@ -2614,17 +2613,16 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, +H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) { H5O_iter_visit_ud_t udata; /* User data for callback */ - H5G_loc_t loc; /* Location of reference object */ H5G_loc_t obj_loc; /* Location used to open object */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ H5O_info_t oinfo; /* Object info struct */ - hid_t obj_id = (-1); /* ID of object */ + hid_t obj_id = H5I_INVALID_HID; /* ID of object */ herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2633,8 +2631,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HDmemset(&udata, 0, sizeof(udata)); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HDassert(loc); /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -2642,7 +2639,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/) < 0) + if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; @@ -2652,7 +2649,7 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Open the object */ /* (Takes ownership of the obj_loc information) */ - if((obj_id = H5O__open_by_loc(&obj_loc, TRUE)) < 0) + if((obj_id = H5O_open_by_loc(&obj_loc, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Make callback for starting object */ @@ -2698,20 +2695,21 @@ H5O__visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Add to list of visited objects */ if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") - } /* end if */ + } /* Call internal group visitation routine */ - if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) + if((ret_value = H5G_visit(&start_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ done: - if(obj_id > 0) { + if(obj_id != H5I_INVALID_HID) { if(H5I_dec_app_ref(obj_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") - } /* end if */ + } else if(loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + if(udata.visited) H5SL_destroy(udata.visited, H5O__free_visit_visited, NULL); |