diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 2 | ||||
-rw-r--r-- | src/H5B2.c | 2 | ||||
-rw-r--r-- | src/H5B2int.c | 10 | ||||
-rw-r--r-- | src/H5Omessage.c | 272 | ||||
-rw-r--r-- | src/H5Oshared.c | 36 |
5 files changed, 96 insertions, 226 deletions
@@ -1248,7 +1248,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op ret_value = (*op)(f, dxpl_id, key + (u * type->sizeof_nkey), child[u], key + ((u + 1) * type->sizeof_nkey), udata); if(ret_value < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed") + HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed"); } /* end for */ } /* end for */ } /* end else */ @@ -289,7 +289,7 @@ H5B2_iterate(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr, if(root_ptr.node_nrec > 0) { /* Iterate through nodes */ if((ret_value = H5B2_iterate_node(f, dxpl_id, bt2_shared, depth, &root_ptr, op, op_data)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); } /* end if */ done: diff --git a/src/H5B2int.c b/src/H5B2int.c index 186d40e..7dc463e 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -2170,14 +2170,14 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, /* Allocate space for the native keys in memory */ if((native = H5FL_FAC_MALLOC(shared->node_info[depth].nat_rec_fac)) == NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree internal native keys") /* Copy the native keys */ HDmemcpy(native, node_native, (shared->type->nrec_size * curr_node->node_nrec)); /* Unlock the node */ if(H5AC_unprotect(f, dxpl_id, curr_node_class, curr_node->addr, node, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") node = NULL; /* Iterate through records, in order */ @@ -2185,20 +2185,20 @@ H5B2_iterate_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, /* Descend into child node, if current node is an internal node */ if(depth > 0) { if((ret_value = H5B2_iterate_node(f, dxpl_id, bt2_shared, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); } /* end if */ /* Make callback for current record */ if(!ret_value) { if((ret_value = (op)(H5B2_NAT_NREC(native, shared, u), op_data)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "iterator function failed") + HERROR(H5E_BTREE, H5E_CANTLIST, "iterator function failed"); } /* end if */ } /* end for */ /* Descend into last child node, if current node is an internal node */ if(!ret_value && depth > 0) { if((ret_value = H5B2_iterate_node(f, dxpl_id, bt2_shared, (depth - 1), &(node_ptrs[u]), op, op_data)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); } /* end if */ done: diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 27c0c02..208d078 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -80,12 +80,9 @@ typedef union { /* Local Prototypes */ /********************/ -static herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, - const void *mesg, unsigned * oh_flags_ptr); -static herr_t H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, - unsigned overwrite, unsigned flags, unsigned update_flags, const void *mesg, - hid_t dxpl_id); +static herr_t H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, + unsigned overwrite, unsigned mesg_flags, unsigned update_flags, + const void *mesg, unsigned *oh_flags_ptr, hid_t dxpl_id); static herr_t H5O_msg_reset_real(const H5O_msg_class_t *type, void *native); static void *H5O_msg_copy_real(const H5O_msg_class_t *type, const void *mesg, void *dst); @@ -95,15 +92,13 @@ static herr_t H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, unsigned *oh_flags_ptr, void *_udata/*in,out*/); static herr_t H5O_msg_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_protect_t prot, hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id); -static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t **type_p, int sequence); static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_msg_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_msg_class_t **new_type, const void **new_mesg, hid_t dxpl_id, - unsigned * oh_flags_ptr); + unsigned *oh_flags_ptr); static herr_t H5O_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, const H5O_msg_class_t *type, const void *mesg, unsigned flags, - unsigned update_flags, unsigned * oh_flags_ptr); + unsigned update_flags, unsigned *oh_flags_ptr); /*********************/ @@ -193,10 +188,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned mesg_flags, - unsigned update_flags, void *mesg, unsigned * oh_flags_ptr) +H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, + unsigned mesg_flags, unsigned update_flags, void *mesg, + unsigned *oh_flags_ptr) { - const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + const H5O_msg_class_t *new_type; /* Actual H5O class type for the ID */ + const void *new_mesg; /* Actual message to write */ + const H5O_msg_class_t *type; /* Original H5O class type for the ID */ + H5O_shared_t sh_mesg; /* Shared object header info */ + unsigned idx; /* Index of message to modify */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ herr_t ret_value = SUCCEED; /* Return value */ @@ -219,56 +219,12 @@ H5O_msg_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned me else if(shared_mesg < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") - if(H5O_msg_append_real(f, dxpl_id, oh, type, mesg_flags, update_flags, mesg, oh_flags_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to append to object header") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_msg_append() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_msg_append_real - * - * Purpose: Simplified version of H5O_msg_create, used when creating a new - * object header message (usually during object creation) and - * several messages will be added to the object header at once. - * - * Return: Success: The sequence number of the message that - * was created. - * - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Dec 31 2002 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - unsigned mesg_flags, unsigned update_flags, const void *mesg, unsigned * oh_flags_ptr) -{ - unsigned idx; /* Index of message to modify */ - H5O_shared_t sh_mesg; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5O_msg_append_real) - - /* check args */ - HDassert(f); - HDassert(oh); - HDassert(type); - HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); - HDassert(mesg); - HDassert(oh_flags_ptr); - /* Create a new message */ - if((idx = H5O_new_mesg(f, oh, &mesg_flags, type, mesg, &sh_mesg, &type, &mesg, dxpl_id, oh_flags_ptr)) == UFAIL) + if((idx = H5O_new_mesg(f, oh, &mesg_flags, type, mesg, &sh_mesg, &new_type, &new_mesg, dxpl_id, oh_flags_ptr)) == UFAIL) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message") /* Write the information to the message */ - if(H5O_write_mesg(f, dxpl_id, oh, idx, type, mesg, mesg_flags, update_flags, oh_flags_ptr) < 0) + if(H5O_write_mesg(f, dxpl_id, oh, idx, new_type, new_mesg, mesg_flags, update_flags, oh_flags_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") #ifdef H5O_DEBUG H5O_assert(oh); @@ -276,7 +232,7 @@ H5O_assert(oh); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_msg_append_real () */ +} /* end H5O_msg_append() */ /*------------------------------------------------------------------------- @@ -310,6 +266,8 @@ herr_t H5O_msg_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite, unsigned mesg_flags, unsigned update_flags, void *mesg, hid_t dxpl_id) { + H5O_t *oh = NULL; /* Object header to use */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotect object header */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ htri_t shared_mesg; /* Whether the message should be shared */ herr_t ret_value = SUCCEED; /* Return value */ @@ -326,6 +284,10 @@ H5O_msg_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite, HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); + /* Check for write access on the file */ + if(0 == (H5F_INTENT(loc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") + /* Should this message be written as a SOHM? */ if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, type_id, mesg)) > 0) /* Mark the message as shared */ @@ -333,11 +295,18 @@ H5O_msg_write(H5O_loc_t *loc, unsigned type_id, unsigned overwrite, else if(shared_mesg < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message") + /* Protect the object header */ + if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + /* Call the "real" modify routine */ - if(H5O_msg_write_real(loc, type, overwrite, mesg_flags, update_flags, mesg, dxpl_id) < 0) + if(H5O_msg_write_real(loc->file, oh, type, overwrite, mesg_flags, update_flags, mesg, &oh_flags, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message") done: + if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_write() */ @@ -368,11 +337,10 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwrite, - unsigned mesg_flags, unsigned update_flags, const void *mesg, hid_t dxpl_id) +H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, + unsigned overwrite, unsigned mesg_flags, unsigned update_flags, + const void *mesg, unsigned *oh_flags_ptr, hid_t dxpl_id) { - H5O_t *oh = NULL; - unsigned oh_flags = H5AC__NO_FLAGS_SET; int sequence; /* Sequence # of message type to modify */ unsigned idx; /* Index of message to modify */ H5O_mesg_t *idx_msg; /* Pointer to message to modify */ @@ -384,20 +352,12 @@ H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwri FUNC_ENTER_NOAPI_NOINIT(H5O_msg_write_real) /* check args */ - HDassert(loc); - HDassert(loc->file); - HDassert(H5F_addr_defined(loc->addr)); + HDassert(f); + HDassert(oh); HDassert(type); HDassert(mesg); HDassert(0 == (mesg_flags & ~H5O_MSG_FLAG_BITS)); - - /* Check for write access on the file */ - if(0 == (H5F_INTENT(loc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file") - - /* Protect the object header */ - if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + HDassert(oh_flags_ptr); /* Count similar messages */ for(idx = 0, sequence = -1, idx_msg = &oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) { @@ -424,7 +384,7 @@ H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwri HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify committed message") /* Remove the old message from the SOHM index */ - if(H5SM_try_delete(loc->file, dxpl_id, oh->mesg[idx].type->id, oh->mesg[idx].native) < 0) + if(H5SM_try_delete(f, dxpl_id, oh->mesg[idx].type->id, oh->mesg[idx].native) < 0) HGOTO_ERROR (H5E_OHDR, H5E_CANTFREE, FAIL, "unable to delete message from SOHM table") /* Now this message is no longer shared and we can safely overwrite it. @@ -438,6 +398,7 @@ H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwri HDassert(H5O_msg_is_shared(type->id, mesg) > 0); /* JAMES: this should work with * replacement messages that aren't shared, too. */ + /* Extract shared message info from current message */ if(H5O_msg_get_share(type->id, mesg, &sh_mesg) < 0) HGOTO_ERROR (H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message") @@ -447,16 +408,13 @@ H5O_msg_write_real(H5O_loc_t *loc, const H5O_msg_class_t *type, unsigned overwri } /* end if */ /* Write the information to the message */ - if(H5O_write_mesg(loc->file, dxpl_id, oh, idx, write_type, write_mesg, mesg_flags, update_flags, &oh_flags) < 0) + if(H5O_write_mesg(f, dxpl_id, oh, idx, write_type, write_mesg, mesg_flags, update_flags, oh_flags_ptr) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message") #ifdef H5O_DEBUG H5O_assert(oh); #endif /* H5O_DEBUG */ done: - if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_write_real() */ @@ -539,10 +497,11 @@ done: *------------------------------------------------------------------------- */ void * -H5O_msg_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id) +H5O_msg_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, + void *mesg, hid_t dxpl_id) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - int idx; + unsigned idx; /* Message's index in object header */ void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT(H5O_msg_read_real) @@ -555,20 +514,31 @@ H5O_msg_read_real(H5F_t *f, H5O_t *oh, unsigned type_id, int sequence, void *mes HDassert(type); HDassert(sequence >= 0); - /* can we get it from the object header? */ - if((idx = H5O_find_in_ohdr(f, dxpl_id, oh, &type, sequence)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find message in object header") + /* Scan through the messages looking for the right one */ + for(idx = 0; idx < oh->nmesgs; idx++) { + if(type_id != oh->mesg[idx].type->id) + continue; + if(--sequence < 0) + break; + } /* end for */ + if(sequence >= 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find object header message") + + /* + * Decode the message if necessary. If the message is shared then decode + * a shared message, ignoring the message type. + */ + H5O_LOAD_NATIVE(f, dxpl_id, &(oh->mesg[idx]), NULL) + /* Read the message in */ if(oh->mesg[idx].flags & H5O_MSG_FLAG_SHARED) { /* * If the message is shared then then the native pointer points to an * H5O_MSG_SHARED message. We use that information to look up the real * message in the global heap or some other object header. */ - H5O_shared_t *shared; - - shared = (H5O_shared_t *)(oh->mesg[idx].native); - ret_value = H5O_shared_read(f, dxpl_id, shared, type, mesg); + if(NULL == (ret_value = H5O_shared_read(f, dxpl_id, oh->mesg[idx].native, type, mesg))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") } else { /* * The message is not shared, but rather exists in the object @@ -598,12 +568,6 @@ done: * matzke@llnl.gov * Aug 12 1997 * - * Modifications: - * Changed to use IDs for types, instead of type objects, then - * call "real" routine. - * Quincey Koziol - * Feb 14 2003 - * *------------------------------------------------------------------------- */ herr_t @@ -679,8 +643,6 @@ done: * Programmer: Robb Matzke * Thursday, May 21, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ void * @@ -781,12 +743,6 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) * Programmer: Robb Matzke * Thursday, May 21, 1998 * - * Modifications: - * Changed to use IDs for types, instead of type objects, then - * call "real" routine. - * Quincey Koziol - * Feb 14 2003 - * *------------------------------------------------------------------------- */ void * @@ -1013,16 +969,6 @@ H5O_msg_exists_oh(H5O_t *oh, unsigned type_id, int sequence) * matzke@llnl.gov * Aug 28 1997 * - * Modifications: - * - * Robb Matzke, 7 Jan 1998 - * Does not remove constant messages. - * - * Changed to use IDs for types, instead of type objects, then - * call "real" routine. - * Quincey Koziol - * Feb 14 2003 - * *------------------------------------------------------------------------- */ herr_t @@ -1310,8 +1256,6 @@ done: * C. Negative causes the iterator to immediately return that value, * indicating failure. * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1364,10 +1308,9 @@ H5O_msg_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_pro idx_msg->native, idx_msg->type, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "unable to read shared message") native_mesg_alloc = TRUE; - } - else { + } /* end if */ + else native_mesg = idx_msg->native; - } /* Call the iterator callback */ if((ret_value = (op.app_op)(native_mesg, sequence, op_data)) != 0) @@ -1377,25 +1320,24 @@ H5O_msg_iterate_real(const H5O_loc_t *loc, const H5O_msg_class_t *type, H5AC_pro if(native_mesg_alloc) { H5O_msg_free(idx_msg->type->id, native_mesg); native_mesg_alloc = FALSE; - } + } /* end if */ } /* end else */ - /* Check for error from iterator */ - if(ret_value < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "iterator function failed") - /* Increment sequence value for message type */ sequence++; } /* end if */ } /* end for */ + /* Check for error from iterator */ + if(ret_value < 0) + HERROR(H5E_OHDR, H5E_CANTLIST, "iterator function failed"); + done: /* Free the native message if it was allocated */ - if(native_mesg_alloc) { + if(native_mesg_alloc) H5O_msg_free(idx_msg->type->id, native_mesg); - native_mesg_alloc = FALSE; - } + /* Object header cleanup */ if(oh) { /* Check if object header was modified */ if(oh_flags & H5AC__DIRTIED_FLAG) { @@ -1410,7 +1352,8 @@ done: if(H5O_condense_header(loc->file, oh, dxpl_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't pack object header") - H5O_touch_oh(loc->file, dxpl_id, oh, FALSE, &oh_flags); + if(H5O_touch_oh(loc->file, dxpl_id, oh, FALSE, &oh_flags) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") } /* end if */ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0) @@ -1802,72 +1745,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_find_in_ohdr - * - * Purpose: Find a message in the object header without consulting - * a symbol table entry. - * - * Return: Success: Index number of message. - * Failure: Negative - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 6 1997 - * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Bill Wendling, 2003-09-30 - * Modified so that the object header needs to be AC_protected - * before calling this function. - *------------------------------------------------------------------------- - */ -static unsigned -H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t **type_p, int sequence) -{ - unsigned u; - unsigned ret_value; - - FUNC_ENTER_NOAPI_NOINIT(H5O_find_in_ohdr) - - /* Check args */ - HDassert(f); - HDassert(oh); - HDassert(type_p); - - /* Scan through the messages looking for the right one */ - for(u = 0; u < oh->nmesgs; u++) { - if(*type_p && (*type_p)->id != oh->mesg[u].type->id) - continue; - if(--sequence < 0) - break; - } /* end for */ - - if(sequence >= 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, UFAIL, "unable to find object header message") - - /* - * Decode the message if necessary. If the message is shared then decode - * a shared message, ignoring the message type. - */ - H5O_LOAD_NATIVE(f, dxpl_id, &(oh->mesg[u]), UFAIL) - - /* - * Return the message type. If this is a shared message then return the - * pointed-to type. - */ - *type_p = oh->mesg[u].type; - - /* Set return value */ - ret_value = u; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_find_in_ohdr() */ - - -/*------------------------------------------------------------------------- * Function: H5O_new_mesg * * Purpose: Create a new message in an object header @@ -1883,7 +1760,7 @@ done: static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_msg_class_t **new_type, - const void **new_mesg, hid_t dxpl_id, unsigned * oh_flags_ptr) + const void **new_mesg, hid_t dxpl_id, unsigned *oh_flags_ptr) { size_t size; /* Size of space allocated for object header */ htri_t is_shared; /* Is this a shared message? */ @@ -1898,8 +1775,8 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o HDassert(orig_type); HDassert(orig_mesg); HDassert(sh_mesg); - HDassert(new_mesg); HDassert(new_type); + HDassert(new_mesg); HDassert(oh_flags_ptr); /* Check for shared message */ @@ -1995,7 +1872,8 @@ H5O_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, /* Update the modification time message if any */ if(update_flags & H5O_UPDATE_TIME) - H5O_touch_oh(f, dxpl_id, oh, FALSE, oh_flags_ptr); + if(H5O_touch_oh(f, dxpl_id, oh, FALSE, oh_flags_ptr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update time on object") /* Mark the object header as modified */ *oh_flags_ptr |= H5AC__DIRTIED_FLAG; diff --git a/src/H5Oshared.c b/src/H5Oshared.c index f84fde6..18d67b7 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -33,9 +33,9 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Gprivate.h" /* Groups */ +#include "H5HFprivate.h" /* Fractal heap */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ -#include "H5HFprivate.h" /* Fractal heap */ #include "H5SMprivate.h" /*JAMES: for H5SM_get_fheap_addr. Change this? */ static void *H5O_shared_decode(H5F_t*, hid_t dxpl_id, const uint8_t*); @@ -143,7 +143,7 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, NULL, "can't get message size from fractal heap.") /* Allocate buffer */ - if(NULL == (buf = HDmalloc(buf_size))) + if(NULL == (buf = H5MM_malloc(buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Retrieve the message from the heap */ @@ -155,7 +155,7 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode shared message.") /* Copy this message to the user's buffer */ - if(NULL == (ret_value = (type->copy) (native_mesg, mesg, 0))) + if(NULL == (ret_value = (type->copy)(native_mesg, mesg, 0))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space") } /* end if */ else { @@ -172,14 +172,13 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, done: if(buf) - HDfree(buf); + H5MM_xfree(buf); if(native_mesg) H5O_msg_free(type->id, native_mesg); - if(fheap) - if(H5HF_close(fheap, dxpl_id) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap") + if(fheap && H5HF_close(fheap, dxpl_id) < 0) + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't close fractal heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shared_read() */ @@ -418,8 +417,6 @@ H5O_shared_encode (H5F_t *f, uint8_t *buf/*out*/, const void *_mesg) * koziol@ncsa.uiuc.edu * Sep 26 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static void * @@ -429,33 +426,28 @@ H5O_shared_copy(const void *_mesg, void *_dest, unsigned UNUSED update_flags) H5O_shared_t *dest = (H5O_shared_t *) _dest; void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy); + FUNC_ENTER_NOAPI_NOINIT(H5O_shared_copy) /* check args */ - assert(mesg); - if (!dest && NULL==(dest = H5MM_malloc (sizeof(H5O_shared_t)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HDassert(mesg); + if(!dest && NULL == (dest = H5MM_malloc(sizeof(H5O_shared_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ dest->flags = mesg->flags; if(mesg->flags & H5O_COMMITTED_FLAG) - { H5O_loc_copy(&(dest->u.oloc), &(mesg->u.oloc), H5_COPY_DEEP); - } else if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) - { - dest->u.heap_id= mesg->u.heap_id; - } else - { + dest->u.heap_id = mesg->u.heap_id; + else /* This message's sharing information is being reset */ HDassert(mesg->flags == H5O_NOT_SHARED); - } /* Set return value */ - ret_value=dest; + ret_value = dest; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shared_copy() */ |