diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 705 | ||||
-rw-r--r-- | src/H5Bcache.c | 8 | ||||
-rw-r--r-- | src/H5Bdbg.c | 148 | ||||
-rw-r--r-- | src/H5Bpkg.h | 1 | ||||
-rw-r--r-- | src/H5Dint.c | 2 | ||||
-rw-r--r-- | src/H5Dtest.c | 8 | ||||
-rw-r--r-- | src/H5Fsuper.c | 4 | ||||
-rw-r--r-- | src/H5HFcache.c | 1 | ||||
-rw-r--r-- | src/H5HFdblock.c | 6 | ||||
-rw-r--r-- | src/H5HFiblock.c | 4 | ||||
-rw-r--r-- | src/H5HG.c | 53 | ||||
-rw-r--r-- | src/H5HL.c | 20 | ||||
-rw-r--r-- | src/H5HLdbg.c | 2 | ||||
-rw-r--r-- | src/H5I.c | 4 | ||||
-rw-r--r-- | src/H5L.c | 2 | ||||
-rw-r--r-- | src/H5O.c | 17 | ||||
-rw-r--r-- | src/H5Oalloc.c | 10 | ||||
-rw-r--r-- | src/H5Ocopy.c | 13 | ||||
-rw-r--r-- | src/H5Omessage.c | 2 | ||||
-rw-r--r-- | src/H5Oprivate.h | 2 | ||||
-rw-r--r-- | src/H5Sall.c | 4 |
21 files changed, 413 insertions, 603 deletions
@@ -202,19 +202,6 @@ H5FL_SEQ_DEFINE_STATIC(size_t); * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * Changed the name of the ADDR argument to ADDR_P to make it - * obvious that the address is passed by reference unlike most - * other functions that take addresses. - * - * John Mainzer 6/9/05 - * Removed code setting the is_dirty field of the cache info. - * This is no longer pemitted, as the cache code is now - * manageing this field. Since this function uses a call to - * H5AC_set() (which marks the entry dirty automaticly), no - * other change is required. - * *------------------------------------------------------------------------- */ herr_t @@ -230,29 +217,29 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, /* * Check arguments. */ - assert(f); - assert(type); - assert(addr_p); + HDassert(f); + HDassert(type); + HDassert(addr_p); /* * Allocate file and memory data structures. */ - if (NULL==(bt = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") + if(NULL == (bt = H5FL_MALLOC(H5B_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") HDmemset(&bt->cache_info, 0, sizeof(H5AC_info_t)); bt->level = 0; bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; bt->nchildren = 0; - if((bt->rc_shared=(type->get_shared)(f, udata))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree node buffer") + if(NULL == (bt->rc_shared = (type->get_shared)(f, udata))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); - if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || - NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") - if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node") + if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || + NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node") + if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node") /* * Cache the new B-tree node. @@ -264,14 +251,14 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, #endif done: - if (ret_value<0) { + if(ret_value < 0) { if(shared && shared->sizeof_rnode>0) { H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ - if (bt) - (void)H5B_dest(f,bt); - } + if(bt) + (void)H5B_dest(f, bt); + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ @@ -298,9 +285,6 @@ done: * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ htri_t @@ -329,7 +313,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u * the thing for which we're searching. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); @@ -349,7 +333,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u /* * Follow the link to the subtree or to the data node. */ - assert(idx < bt->nchildren); + HDassert(idx < bt->nchildren); if(bt->level > 0) { if((ret_value = H5B_find(f, dxpl_id, type, bt->child[idx], udata)) < 0) @@ -362,7 +346,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_find() */ @@ -388,20 +372,6 @@ done: * matzke@llnl.gov * Jul 3 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The OLD_ADDR argument is passed by value. The NEW_ADDR - * argument has been renamed to NEW_ADDR_P - * - * John Mainzer, 6/9/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * - * In this case, that required adding the new - * old_bt_dirtied_ptr parameter to the function's argument - * list. - * *------------------------------------------------------------------------- */ static herr_t @@ -421,39 +391,38 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, /* * Check arguments. */ - assert(f); - assert(old_bt); - assert(old_bt_flags); - assert(H5F_addr_defined(old_addr)); + HDassert(f); + HDassert(old_bt); + HDassert(old_bt_flags); + HDassert(H5F_addr_defined(old_addr)); /* * Initialize variables. */ - shared=(H5B_shared_t *)H5RC_GET_OBJ(old_bt->rc_shared); + shared = (H5B_shared_t *)H5RC_GET_OBJ(old_bt->rc_shared); HDassert(shared); - assert(old_bt->nchildren == shared->two_k); + HDassert(old_bt->nchildren == shared->two_k); /* Get the dataset transfer property list */ - if (NULL == (dx_plist = (H5P_genplist_t *)H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + if(NULL == (dx_plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get B-tree split ratios */ - if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios[0])<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios") + if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios[0]) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree split ratios") #ifdef H5B_DEBUG - if (H5DEBUG(B)) { + if(H5DEBUG(B)) { const char *side; - if (!H5F_addr_defined(old_bt->left) && - !H5F_addr_defined(old_bt->right)) { + + if(!H5F_addr_defined(old_bt->left) && !H5F_addr_defined(old_bt->right)) side = "ONLY"; - } else if (!H5F_addr_defined(old_bt->right)) { + else if(!H5F_addr_defined(old_bt->right)) side = "RIGHT"; - } else if (!H5F_addr_defined(old_bt->left)) { + else if(!H5F_addr_defined(old_bt->left)) side = "LEFT"; - } else { + else side = "MIDDLE"; - } fprintf(H5DEBUG(B), "H5B_split: %3u {%5.3f,%5.3f,%5.3f} %6s", shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side); } @@ -463,37 +432,35 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, * Decide how to split the children of the old node among the old node * and the new node. */ - if (!H5F_addr_defined(old_bt->right)) { + if(!H5F_addr_defined(old_bt->right)) nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/ - } else if (!H5F_addr_defined(old_bt->left)) { + else if(!H5F_addr_defined(old_bt->left)) nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/ - } else { + else nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/ - } /* * Keep the new child in the same node as the child that split. This can * result in nodes that have an unused child when data is written * sequentially, but it simplifies stuff below. */ - if (idx<nleft && nleft==shared->two_k) { + if(idx < nleft && nleft == shared->two_k) --nleft; - } else if (idx>=nleft && 0==nleft) { + else if(idx >= nleft && 0 == nleft) nleft++; - } nright = shared->two_k - nleft; #ifdef H5B_DEBUG - if (H5DEBUG(B)) + if(H5DEBUG(B)) fprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright); #endif /* * Create the new B-tree node. */ - if (H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0) + if(H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") if(NULL == (new_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree") new_bt->level = old_bt->level; /* @@ -510,10 +477,10 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, new_bt_flags |= H5AC__DIRTIED_FLAG; HDmemcpy(new_bt->native, old_bt->native + nleft * shared->type->sizeof_nkey, - (nright+1) * shared->type->sizeof_nkey); + (nright + 1) * shared->type->sizeof_nkey); HDmemcpy(new_bt->child, &old_bt->child[nleft], - nright*sizeof(haddr_t)); + nright * sizeof(haddr_t)); new_bt->nchildren = nright; @@ -533,19 +500,19 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, H5B_t *tmp_bt; if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling") tmp_bt->left = *new_addr_p; if(H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") } /* end if */ old_bt->right = *new_addr_p; done: if(new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt, new_bt_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_split() */ @@ -563,25 +530,6 @@ done: * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 28 Sep 1998 - * The optional SPLIT_RATIOS[] indicates what percent of the child - * pointers should go in the left node when a node splits. There are - * three possibilities and a separate split ratio can be specified for - * each: [0] The node that split is the left-most node at its level of - * the tree, [1] the node that split has left and right siblings, [2] - * the node that split is the right-most node at its level of the tree. - * When a node is an only node at its level then we use the right-most - * rule. If SPLIT_RATIOS is null then default values are used. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * John Mainzer, 6/9/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -608,42 +556,42 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, FUNC_ENTER_NOAPI(H5B_insert, FAIL) /* Check arguments. */ - assert(f); - assert(type); - assert(type->sizeof_nkey <= sizeof _lt_key); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(type); + HDassert(type->sizeof_nkey <= sizeof _lt_key); + HDassert(H5F_addr_defined(addr)); - if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key, - <_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0) + if((int)(my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key, + <_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") - if (H5B_INS_NOOP == my_ins) + if(H5B_INS_NOOP == my_ins) HGOTO_DONE(SUCCEED) HDassert(H5B_INS_RIGHT == my_ins); /* the current root */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to locate root of B-tree") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); level = bt->level; - if (!lt_key_changed) + if(!lt_key_changed) HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child") bt = NULL; /* the new node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new node") - if (!rt_key_changed) + if(!rt_key_changed) HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child") bt = NULL; /* @@ -652,17 +600,17 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, * from "moving". */ H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); - if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root") + if(HADDR_UNDEF == (old_root = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root") /* update the new child's left pointer */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new child") bt->left = old_root; if(H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child") bt = NULL; /* Make certain future references will be caught */ /* @@ -671,23 +619,23 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, */ /* Bring the old root into the cache if it's not already */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new child") /* Make certain the old root info is marked as dirty before moving it, */ /* so it is certain to be written out at the new location */ /* Make a copy of the old root information */ - if (NULL == (new_bt = H5B_copy(bt))) { - HCOMMON_ERROR(H5E_BTREE, H5E_CANTLOAD, "unable to copy old root"); + if(NULL == (new_bt = H5B_copy(bt))) { + HCOMMON_ERROR(H5E_BTREE, H5E_CANTCOPY, "unable to copy old root"); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child") HGOTO_DONE(FAIL) - } + } /* end if */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child") bt = NULL; /* Make certain future references will be caught */ /* Move the location of the old root on the disk */ @@ -736,18 +684,6 @@ done: * matzke@llnl.gov * Jul 8 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The CHILD argument is passed by value. - * - * John Mainzer, 6/9/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * - * In this case, that required adding the new dirtied_ptr - * parameter to the function's argument list. - * *------------------------------------------------------------------------- */ static herr_t @@ -759,28 +695,28 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child) - assert(bt); - assert(bt_flags); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + HDassert(bt); + HDassert(bt_flags); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); - assert(bt->nchildren<shared->two_k); + HDassert(bt->nchildren < shared->two_k); /* Check for inserting right-most key into node (common when just appending * records to an unlimited dimension chunked dataset) */ - base=H5B_NKEY(bt,shared,(idx+1)); - if((idx+1)==bt->nchildren) { + base = H5B_NKEY(bt, shared, (idx + 1)); + if((idx + 1) == bt->nchildren) { /* Make room for the new key */ HDmemcpy(base + shared->type->sizeof_nkey, base, shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */ HDmemcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if (H5B_INS_RIGHT == anchor) + if(H5B_INS_RIGHT == anchor) idx++; /* Don't have to memmove() child addresses down, just add new child */ else /* Make room for the new child address */ - bt->child[idx+1] = bt->child[idx]; + bt->child[idx + 1] = bt->child[idx]; } /* end if */ else { /* Make room for the new key */ @@ -789,7 +725,7 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, HDmemcpy(base, md_key, shared->type->sizeof_nkey); /* The MD_KEY is the left key of the new node */ - if (H5B_INS_RIGHT == anchor) + if(H5B_INS_RIGHT == anchor) idx++; /* Make room for the new child address */ @@ -836,27 +772,6 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, * matzke@llnl.gov * Jul 9 1997 * - * Modifications: - * - * Robb Matzke, 28 Sep 1998 - * The optional SPLIT_RATIOS[] indicates what percent of the child - * pointers should go in the left node when a node splits. There are - * three possibilities and a separate split ratio can be specified for - * each: [0] The node that split is the left-most node at its level of - * the tree, [1] the node that split has left and right siblings, [2] - * the node that split is the right-most node at its level of the tree. - * When a node is an only node at its level then we use the right-most - * rule. If SPLIT_RATIOS is null then default values are used. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. The NEW_NODE argument is - * renamed NEW_NODE_P - * - * John Mainzer, 6/9/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -880,17 +795,17 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type /* * Check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(type); - assert(type->decode); - assert(type->cmp3); - assert(type->new_node); - assert(lt_key); - assert(lt_key_changed); - assert(rt_key); - assert(rt_key_changed); - assert(new_node_p); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(type); + HDassert(type->decode); + HDassert(type->cmp3); + HDassert(type->new_node); + HDassert(lt_key); + HDassert(lt_key_changed); + HDassert(rt_key); + HDassert(rt_key_changed); + HDassert(new_node_p); *lt_key_changed = FALSE; *rt_key_changed = FALSE; @@ -901,63 +816,61 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * should get the new data. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; - while (lt < rt && cmp) { + while(lt < rt && cmp) { idx = (lt + rt) / 2; - if ((cmp = (type->cmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { + if((cmp = (type->cmp3)(f, dxpl_id, H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) rt = idx; - } else { + else lt = idx + 1; - } - } + } /* end while */ - if (0 == bt->nchildren) { + if(0 == bt->nchildren) { /* * The value being inserted will be the only value in this tree. We * must necessarily be at level zero. */ - assert(0 == bt->level); - if ((type->new_node)(f, dxpl_id, H5B_INS_FIRST, H5B_NKEY(bt,shared,0), udata, - H5B_NKEY(bt,shared,1), bt->child + 0/*out*/) < 0) + HDassert(0 == bt->level); + if((type->new_node)(f, dxpl_id, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata, + H5B_NKEY(bt, shared, 1), bt->child + 0/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") bt->nchildren = 1; bt_flags |= H5AC__DIRTIED_FLAG; idx = 0; - if (type->follow_min) { - if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), + if(type->follow_min) { + if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") - } else { + } /* end if */ + else my_ins = H5B_INS_NOOP; - } - - } else if (cmp < 0 && idx == 0 && bt->level > 0) { + } else if(cmp < 0 && idx == 0 && bt->level > 0) { /* * The value being inserted is less than any value in this tree. * Follow the minimum branch out of this node to a subtree. */ - if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, + if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, - udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed, - &child_addr/*out*/))<0) + udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, + &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree") - } else if (cmp < 0 && idx == 0 && type->follow_min) { + } else if(cmp < 0 && idx == 0 && type->follow_min) { /* * The value being inserted is less than any leaf node out of this * current node. Follow the minimum branch to a leaf node and let the * subclass handle the problem. */ - if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), + if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") - } else if (cmp < 0 && idx == 0) { + } else if(cmp < 0 && idx == 0) { /* * The value being inserted is less than any leaf node out of the * current node. Create a new minimum leaf node out of this B-tree @@ -965,33 +878,32 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ my_ins = H5B_INS_LEFT; HDmemcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); - if ((type->new_node)(f, dxpl_id, H5B_INS_LEFT, H5B_NKEY(bt,shared,idx), udata, - md_key, &child_addr/*out*/) < 0) + if((type->new_node)(f, dxpl_id, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata, + md_key, &child_addr/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") *lt_key_changed = TRUE; - - } else if (cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) { + } else if(cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) { /* * The value being inserted is larger than any value in this tree. * Follow the maximum branch out of this node to a subtree. */ idx = bt->nchildren - 1; - if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, - H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) + if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, + H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree") - } else if (cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) { + } else if(cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) { /* * The value being inserted is larger than any leaf node out of the * current node. Follow the maximum branch to a leaf node and let the * subclass handle the problem. */ idx = bt->nchildren - 1; - if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), + if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") - } else if (cmp > 0 && idx + 1 >= bt->nchildren) { + } else if(cmp > 0 && idx + 1 >= bt->nchildren) { /* * The value being inserted is larger than any leaf node out of the * current node. Create a new maximum leaf node out of this B-tree @@ -999,80 +911,78 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ idx = bt->nchildren - 1; my_ins = H5B_INS_RIGHT; - HDmemcpy(md_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); - if ((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata, - H5B_NKEY(bt,shared,idx+1), &child_addr/*out*/) < 0) + HDmemcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); + if((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), &child_addr/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") *rt_key_changed = TRUE; - - } else if (cmp) { + } else if(cmp) { /* * We couldn't figure out which branch to follow out of this node. THIS * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. */ - assert("INTERNAL HDF5 ERROR (contact rpm)" && 0); + HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0); #ifdef NDEBUG HDabort(); #endif /* NDEBUG */ - } else if (bt->level > 0) { + } else if(bt->level > 0) { /* * Follow a branch out of this node to another subtree. */ - assert(idx < bt->nchildren); - if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, - H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata, - H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0) + HDassert(idx < bt->nchildren); + if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, + H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") } else { /* * Follow a branch out of this node to a leaf node of some other type. */ - assert(idx < bt->nchildren); - if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), - lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1), + HDassert(idx < bt->nchildren); + if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx), + lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") } - assert((int)my_ins >= 0); + HDassert((int)my_ins >= 0); /* * Update the left and right keys of the current node. */ - if (*lt_key_changed) { + if(*lt_key_changed) { bt_flags |= H5AC__DIRTIED_FLAG; - if (idx > 0) + if(idx > 0) *lt_key_changed = FALSE; else - HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); - } - if (*rt_key_changed) { + HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); + } /* end if */ + if(*rt_key_changed) { bt_flags |= H5AC__DIRTIED_FLAG; - if (idx+1 < bt->nchildren) + if(idx + 1 < bt->nchildren) *rt_key_changed = FALSE; else - HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); - } - if (H5B_INS_CHANGE == my_ins) { + HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); + } /* end if */ + if(H5B_INS_CHANGE == my_ins) { /* * The insertion simply changed the address for the child. */ bt->child[idx] = child_addr; bt_flags |= H5AC__DIRTIED_FLAG; ret_value = H5B_INS_NOOP; - - } else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { + } else if(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { hbool_t *tmp_bt_flags_ptr = NULL; H5B_t *tmp_bt; /* * If this node is full then split it before inserting the new child. */ - if (bt->nchildren == shared->two_k) { - if (H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/)<0) + if(bt->nchildren == shared->two_k) { + if(H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") - if (NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") - if (idx<bt->nchildren) { + if(NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node") + if(idx < bt->nchildren) { tmp_bt = bt; tmp_bt_flags_ptr = &bt_flags; } else { @@ -1080,13 +990,14 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type tmp_bt = twin; tmp_bt_flags_ptr = &twin_flags; } - } else { + } /* end if */ + else { tmp_bt = bt; tmp_bt_flags_ptr = &bt_flags; - } + } /* end else */ /* Insert the child */ - if (H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, child_addr, my_ins, md_key) < 0) + if(H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, child_addr, my_ins, md_key) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") } @@ -1094,28 +1005,28 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * If this node split, return the mid key (the one that is shared * by the left and right node). */ - if (twin) { - HDmemcpy(md_key, H5B_NKEY(twin,shared,0), type->sizeof_nkey); + if(twin) { + HDmemcpy(md_key, H5B_NKEY(twin, shared, 0), type->sizeof_nkey); ret_value = H5B_INS_RIGHT; #ifdef H5B_DEBUG /* * The max key in the original left node must be equal to the min key * in the new node. */ - cmp = (type->cmp2)(f, dxpl_id, H5B_NKEY(bt,shared,bt->nchildren), udata, - H5B_NKEY(twin,shared,0)); - assert(0 == cmp); + cmp = (type->cmp2)(f, dxpl_id, H5B_NKEY(bt, shared, bt->nchildren), udata, + H5B_NKEY(twin, shared, 0)); + HDassert(0 == cmp); #endif - } else { + } /* end if */ + else ret_value = H5B_INS_NOOP; - } done: { herr_t e1 = (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) < 0); herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p, twin, twin_flags) < 0); - if (e1 || e2) /*use vars to prevent short-circuit of side effects */ - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)") + if(e1 || e2) /*use vars to prevent short-circuit of side effects */ + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node(s)") } FUNC_LEAVE_NOAPI(ret_value) @@ -1158,14 +1069,14 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Protect the initial/current node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node") if(bt->level > 0) { haddr_t left_child = bt->child[0]; /* Address of left-most child in node */ /* Release current node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") bt = NULL; /* Keep following the left-most child until we reach a leaf node. */ @@ -1183,9 +1094,9 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Allocate space for a copy of the native records & child pointers */ if(NULL == (native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys))) - HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records") if(NULL == (child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for shared B-tree child addresses") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree child addresses") /* Cache information from this node */ nchildren = bt->nchildren; @@ -1197,7 +1108,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Release current node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") bt = NULL; /* @@ -1227,7 +1138,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Protect the next node to the right */ addr = next_addr; if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5_ITER_ERROR, "B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "B-tree node") /* Cache information from this node */ nchildren = bt->nchildren; @@ -1239,7 +1150,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Unprotect node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") bt = NULL; } /* end if */ else @@ -1251,7 +1162,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node") if(native) (void)H5FL_BLK_FREE(native_block, native); if(child) @@ -1322,15 +1233,6 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, * Programmer: Robb Matzke * Wednesday, September 16, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * John Mainzer, 6/10/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -1341,64 +1243,63 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type { H5B_t *bt = NULL, *sibling = NULL; unsigned bt_flags = H5AC__NO_FLAGS_SET; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - unsigned idx=0, lt=0, rt; /* Final, left & right indices */ - int cmp=1; /* Key comparison value */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ + int cmp = 1; /* Key comparison value */ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI(H5B_remove_helper, H5B_INS_ERROR) - assert(f); - assert(H5F_addr_defined(addr)); - assert(type); - assert(type->decode); - assert(type->cmp3); - assert(lt_key && lt_key_changed); - assert(udata); - assert(rt_key && rt_key_changed); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(type); + HDassert(type->decode); + HDassert(type->cmp3); + HDassert(lt_key && lt_key_changed); + HDassert(udata); + HDassert(rt_key && rt_key_changed); /* * Perform a binary search to locate the child which contains the thing * for which we're searching. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; - while (lt<rt && cmp) { - idx = (lt+rt)/2; - if ((cmp=(type->cmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1)))<0) { + while(lt < rt && cmp) { + idx = (lt + rt) / 2; + if((cmp = (type->cmp3)(f, dxpl_id, H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0) rt = idx; - } else { - lt = idx+1; - } - } - if (cmp) + else + lt = idx + 1; + } /* end while */ + if(cmp) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") /* * Follow the link to the subtree or to the data node. The return value * will be one of H5B_INS_ERROR, H5B_INS_NOOP, or H5B_INS_REMOVE. */ - assert(idx<bt->nchildren); - if (bt->level>0) { + HDassert(idx < bt->nchildren); + if(bt->level > 0) { /* We're at an internal node -- call recursively */ - if ((int)(ret_value=H5B_remove_helper(f, dxpl_id, - bt->child[idx], type, level+1, H5B_NKEY(bt,shared,idx)/*out*/, - lt_key_changed/*out*/, udata, H5B_NKEY(bt,shared,idx+1)/*out*/, - rt_key_changed/*out*/))<0) + if((int)(ret_value = H5B_remove_helper(f, dxpl_id, + bt->child[idx], type, level + 1, H5B_NKEY(bt, shared, idx)/*out*/, + lt_key_changed/*out*/, udata, H5B_NKEY(bt, shared, idx + 1)/*out*/, + rt_key_changed/*out*/)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") - } else if (type->remove) { + } else if(type->remove) { /* * We're at a leaf node but the leaf node points to an object that * has a removal method. Pass the removal request to the pointed-to * object and let it decide how to progress. */ - if ((int)(ret_value=(type->remove)(f, dxpl_id, - bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, udata, - H5B_NKEY(bt,shared,idx+1), rt_key_changed))<0) + if((int)(ret_value = (type->remove)(f, dxpl_id, + bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, udata, + H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") } else { /* @@ -1419,48 +1320,49 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * key changed and it's the right most key of this node we must update * our right key and indicate that it changed. */ - if (*lt_key_changed) { + if(*lt_key_changed) { bt_flags |= H5AC__DIRTIED_FLAG; - if (idx>0) + if(idx > 0) /* Don't propagate change out of this B-tree node */ *lt_key_changed = FALSE; else - HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey); - } - if (*rt_key_changed) { + HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey); + } /* end if */ + if(*rt_key_changed) { bt_flags |= H5AC__DIRTIED_FLAG; - if (idx+1<bt->nchildren) { + if(idx + 1 < bt->nchildren) { /* Don't propagate change out of this B-tree node */ *rt_key_changed = FALSE; - } else { - HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); + } /* end if */ + else { + HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); /* Since our right key was changed, we must check for a right * sibling and change it's left-most key as well. * (Handle the ret_value==H5B_INS_REMOVE case below) */ - if (ret_value!=H5B_INS_REMOVE && level>0) { - if (H5F_addr_defined(bt->right)) { + if(ret_value != H5B_INS_REMOVE && level > 0) { + if(H5F_addr_defined(bt->right)) { if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ - HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey); + HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling=NULL; /* Make certain future references will be caught */ - } - } - } - } + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + } /* end if */ + } /* end else */ + } /* end if */ /* * If the subtree returned H5B_INS_REMOVE then we should remove the * subtree entry from the current node. There are four cases: */ - if (H5B_INS_REMOVE==ret_value && 1==bt->nchildren) { + if(H5B_INS_REMOVE == ret_value && 1 == bt->nchildren) { /* * The subtree is the only child of this node. Discard both * keys and the subtree pointer. Free this node (unless it's the @@ -1468,42 +1370,42 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ bt_flags |= H5AC__DIRTIED_FLAG; bt->nchildren = 0; - if (level>0) { - if (H5F_addr_defined(bt->left)) { + if(level > 0) { + if(H5F_addr_defined(bt->left)) { if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node from tree") sibling->right = bt->right; if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling=NULL; /* Make certain future references will be caught */ - } - if (H5F_addr_defined(bt->right)) { + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + if(H5F_addr_defined(bt->right)) { if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in it's right neighbor */ - HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,0), type->sizeof_nkey); + HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, 0), type->sizeof_nkey); sibling->left = bt->left; if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling=NULL; /* Make certain future references will be caught */ - } + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; - H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t); + H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) { bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to free B-tree node") } /* end if */ bt = NULL; bt_flags = H5AC__NO_FLAGS_SET; } /* end if */ - } else if (H5B_INS_REMOVE==ret_value && 0==idx) { + } else if(H5B_INS_REMOVE == ret_value && 0 == idx) { /* * The subtree is the left-most child of this node. We discard the * left-most key and the left-most child (the child has already been @@ -1516,15 +1418,14 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type HDmemmove(bt->native, bt->native + type->sizeof_nkey, - (bt->nchildren+1) * type->sizeof_nkey); + (bt->nchildren + 1) * type->sizeof_nkey); HDmemmove(bt->child, - bt->child+1, + bt->child + 1, bt->nchildren * sizeof(haddr_t)); - HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey); + HDmemcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey); *lt_key_changed = TRUE; ret_value = H5B_INS_NOOP; - - } else if (H5B_INS_REMOVE==ret_value && idx+1==bt->nchildren) { + } else if(H5B_INS_REMOVE == ret_value && idx + 1 == bt->nchildren) { /* * The subtree is the right-most child of this node. We discard the * right-most key and the right-most child (the child has already been @@ -1533,29 +1434,28 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ bt_flags |= H5AC__DIRTIED_FLAG; bt->nchildren -= 1; - HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); + HDmemcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); *rt_key_changed = TRUE; /* Since our right key was changed, we must check for a right * sibling and change it's left-most key as well. * (Handle the ret_value==H5B_INS_REMOVE case below) */ - if (level>0) { - if (H5F_addr_defined(bt->right)) { + if(level > 0) { + if(H5F_addr_defined(bt->right)) { if(NULL == (sibling = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree") - HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey); + HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__DIRTIED_FLAG) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree") - sibling=NULL; /* Make certain future references will be caught */ - } - } + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree") + sibling = NULL; /* Make certain future references will be caught */ + } /* end if */ + } /* end if */ ret_value = H5B_INS_NOOP; - - } else if (H5B_INS_REMOVE==ret_value) { + } else if(H5B_INS_REMOVE == ret_value) { /* * There are subtrees out of this node to both the left and right of * the subtree being removed. The key to the left of the subtree and @@ -1567,20 +1467,18 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type bt->nchildren -= 1; HDmemmove(bt->native + idx * type->sizeof_nkey, - bt->native + (idx+1) * type->sizeof_nkey, - (bt->nchildren+1-idx) * type->sizeof_nkey); - HDmemmove(bt->child+idx, - bt->child+idx+1, - (bt->nchildren-idx) * sizeof(haddr_t)); + bt->native + (idx + 1) * type->sizeof_nkey, + (bt->nchildren + 1 - idx) * type->sizeof_nkey); + HDmemmove(bt->child + idx, + bt->child + idx + 1, + (bt->nchildren - idx) * sizeof(haddr_t)); ret_value = H5B_INS_NOOP; - - } else { + } else ret_value = H5B_INS_NOOP; - } done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node") FUNC_LEAVE_NOAPI(ret_value) } @@ -1600,15 +1498,6 @@ done: * Programmer: Robb Matzke * Wednesday, September 16, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * John Mainzer, 6/8/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -1627,14 +1516,14 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void FUNC_ENTER_NOAPI(H5B_remove, FAIL) /* Check args */ - assert(f); - assert(type); - assert(type->sizeof_nkey <= sizeof _lt_key); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(type); + HDassert(type->sizeof_nkey <= sizeof _lt_key); + HDassert(H5F_addr_defined(addr)); /* The actual removal */ - if (H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, <_key_changed, - udata, rt_key, &rt_key_changed)==H5B_INS_ERROR) + if(H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, <_key_changed, + udata, rt_key, &rt_key_changed) == H5B_INS_ERROR) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") /* @@ -1642,16 +1531,16 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void * being at level zero */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree root node") - if (0==bt->nchildren && 0!=bt->level) { + if(0 == bt->nchildren && 0 != bt->level) { bt->level = 0; bt_flags |= H5AC__DIRTIED_FLAG; - } + } /* end if */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node") - bt=NULL; /* Make certain future references will be caught */ + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node") + bt = NULL; /* Make certain future references will be caught */ #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, addr, type, udata); @@ -1672,54 +1561,48 @@ done: * Programmer: Quincey Koziol * Thursday, March 20, 2003 * - * Modifications: - * - * John Mainzer, 6/10/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; /* B-tree node being operated on */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_delete, FAIL) /* Check args */ - assert(f); - assert(type); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(type); + HDassert(H5F_addr_defined(addr)); /* Lock this B-tree node into memory for now */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* Iterate over all children in tree, deleting them */ - if (bt->level > 0) { + if(bt->level > 0) { /* Iterate over all children in node, deleting them */ - for (u=0; u<bt->nchildren; u++) - if (H5B_delete(f, dxpl_id, type, bt->child[u], udata)<0) + for(u = 0; u < bt->nchildren; u++) + if(H5B_delete(f, dxpl_id, type, bt->child[u], udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node") - } else { + } /* end if */ + else { hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */ /* Check for removal callback */ if(type->remove) { /* Iterate over all entries in node, calling callback */ - for (u=0; u<bt->nchildren; u++) { + for(u = 0; u < bt->nchildren; u++) { /* Call user's callback for each entry */ - if ((type->remove)(f, dxpl_id, - bt->child[u], H5B_NKEY(bt,shared,u), <_key_changed, udata, - H5B_NKEY(bt,shared,u+1), &rt_key_changed)<H5B_INS_NOOP) + if((type->remove)(f, dxpl_id, + bt->child[u], H5B_NKEY(bt, shared, u), <_key_changed, udata, + H5B_NKEY(bt, shared, u + 1), &rt_key_changed) < H5B_INS_NOOP) HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node") } /* end for */ } /* end if */ @@ -1727,7 +1610,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ @@ -1851,8 +1734,6 @@ H5B_shared_free(void *_shared) * koziol@ncsa.uiuc.edu * Apr 18 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5B_t * @@ -1873,7 +1754,7 @@ H5B_copy(const H5B_t *old_bt) /* Allocate memory for the new H5B_t object */ if(NULL == (new_node = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ HDmemcpy(new_node, old_bt, sizeof(H5B_t)); @@ -1883,7 +1764,7 @@ H5B_copy(const H5B_t *old_bt) if(NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) || NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ HDmemcpy(new_node->native, old_bt->native, shared->sizeof_keys); @@ -1947,7 +1828,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Protect the initial/current node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") /* Get the shared B-tree information */ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); @@ -1967,7 +1848,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Release current node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; /* @@ -1978,7 +1859,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Protect the next node to the right */ addr = next_addr; if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "B-tree node") /* Cache information from this node */ next_addr = bt->right; @@ -1989,7 +1870,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Unprotect node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") bt = NULL; } /* end while */ @@ -2002,7 +1883,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_get_info_helper() */ @@ -2087,7 +1968,7 @@ H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr) HDassert(type); if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "address is undefined") + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, FAIL, "address is undefined") /* Protect the node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, NULL, H5AC_READ))) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index dc60f9d..cc5bbbf 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -225,8 +225,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) UINT16DECODE(p, bt->nchildren); /* sibling pointers */ - H5F_addr_decode(f, (const uint8_t **) &p, &(bt->left)); - H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right)); + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->left)); + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->right)); /* the child/key pairs */ native = bt->native; @@ -238,7 +238,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) native += type->sizeof_nkey; /* Decode address value */ - H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); + H5F_addr_decode(f, (const uint8_t **)&p, bt->child + u); } /* end for */ /* Decode final key */ @@ -275,7 +275,7 @@ done: static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, unsigned UNUSED * flags_ptr) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B_flush) diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 1549693..aafb999 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -30,6 +30,7 @@ #define H5B_PACKAGE /*suppress error about including H5Bpkg */ + /***********/ /* Headers */ /***********/ @@ -38,6 +39,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ + /*------------------------------------------------------------------------- * Function: H5B_debug @@ -50,9 +52,6 @@ * matzke@llnl.gov * Aug 4 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t @@ -60,28 +59,28 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5B_debug, FAIL) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); - assert(type); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); + HDassert(type); /* * Load the tree node. */ - if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* @@ -89,8 +88,8 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", - ((shared->type->id)==H5B_SNODE_ID ? "H5B_SNODE_ID" : - ((shared->type->id)==H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); + ((shared->type->id) == H5B_SNODE_ID ? "H5B_SNODE_ID" : + ((shared->type->id) == H5B_CHUNK_ID ? "H5B_CHUNK_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", shared->sizeof_rnode); @@ -103,15 +102,12 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Level:", bt->level); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of left sibling:", bt->left); - HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of right sibling:", bt->right); - HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of children (max):", bt->nchildren, shared->two_k); @@ -119,35 +115,35 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f /* * Print the child addresses */ - for (u = 0; u < bt->nchildren; u++) { + for(u = 0; u < bt->nchildren; u++) { HDfprintf(stream, "%*sChild %d...\n", indent, "", u); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ - if (type->debug_key) { + if(type->debug_key) { /* Decode the 'left' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); - assert(H5B_NKEY(bt,shared,u)); - (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), - H5B_NKEY(bt,shared,u), udata); + HDassert(H5B_NKEY(bt,shared,u)); + (void)(type->debug_key)(stream, f, dxpl_id, indent + 6, MAX(0, fwidth - 6), + H5B_NKEY(bt, shared, u), udata); /* Decode the 'right' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); - assert(H5B_NKEY(bt,shared,u+1)); - (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), - H5B_NKEY(bt,shared,u+1), udata); - } - } + HDassert(H5B_NKEY(bt, shared, u + 1)); + (void)(type->debug_key)(stream, f, dxpl_id, indent + 6, MAX (0, fwidth - 6), + H5B_NKEY(bt, shared, u + 1), udata); + } /* end if */ + } /* end for */ done: - if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") + if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5B_debug() */ /*------------------------------------------------------------------------- @@ -162,15 +158,6 @@ done: * Programmer: Robb Matzke * Tuesday, November 4, 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * John Mainzer, 6/8/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ #ifdef H5B_DEBUG @@ -178,11 +165,11 @@ herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ int i, ncell, cmp; static int ncalls = 0; herr_t status; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ /* A queue of child data */ struct child_t { @@ -193,25 +180,25 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void FUNC_ENTER_NOAPI_NOFUNC(H5B_assert) - if (0==ncalls++) { - if (H5DEBUG(B)) { + if(0 == ncalls++) { + if(H5DEBUG(B)) fprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n"); - } - } + } /* end if */ + /* Initialize the queue */ bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ); - assert(bt); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + HDassert(bt); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); cur = H5MM_calloc(sizeof(struct child_t)); - assert (cur); + HDassert(cur); cur->addr = addr; cur->level = bt->level; head = tail = cur; status = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__NO_FLAGS_SET); - assert(status >= 0); - bt=NULL; /* Make certain future references will be caught */ + HDassert(status >= 0); + bt = NULL; /* Make certain future references will be caught */ /* * Do a breadth-first search of the tree. New nodes are added to the end @@ -219,37 +206,33 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void * remove any nodes from the queue because we need them in the uniqueness * test. */ - for (ncell = 0; cur; ncell++) { + for(ncell = 0; cur; ncell++) { bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata, H5AC_READ); - assert(bt); + HDassert(bt); /* Check node header */ - assert(bt->level == cur->level); - if (cur->next && cur->next->level == bt->level) { - assert(H5F_addr_eq(bt->right, cur->next->addr)); - } else { - assert(!H5F_addr_defined(bt->right)); - } - if (prev && prev->level == bt->level) { - assert(H5F_addr_eq(bt->left, prev->addr)); - } else { - assert(!H5F_addr_defined(bt->left)); - } - - if (cur->level > 0) { - for (i = 0; i < bt->nchildren; i++) { - + HDassert(bt->level == cur->level); + if(cur->next && cur->next->level == bt->level) + HDassert(H5F_addr_eq(bt->right, cur->next->addr)); + else + HDassert(!H5F_addr_defined(bt->right)); + if(prev && prev->level == bt->level) + HDassert(H5F_addr_eq(bt->left, prev->addr)); + else + HDassert(!H5F_addr_defined(bt->left)); + + if(cur->level > 0) { + for(i = 0; i < bt->nchildren; i++) { /* * Check that child nodes haven't already been seen. If they * have then the tree has a cycle. */ - for (tmp = head; tmp; tmp = tmp->next) { - assert(H5F_addr_ne(tmp->addr, bt->child[i])); - } + for(tmp = head; tmp; tmp = tmp->next) + HDassert(H5F_addr_ne(tmp->addr, bt->child[i])); /* Add the child node to the end of the queue */ tmp = H5MM_calloc(sizeof(struct child_t)); - assert (tmp); + HDassert(tmp); tmp->addr = bt->child[i]; tmp->level = bt->level - 1; tail->next = tmp; @@ -258,27 +241,28 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void /* Check that the keys are monotonically increasing */ cmp = (type->cmp2)(f, dxpl_id, H5B_NKEY(bt, shared, i), udata, H5B_NKEY(bt, shared, i + 1)); - assert(cmp < 0); - } - } + HDassert(cmp < 0); + } /* end for */ + } /* end if */ + /* Release node */ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, H5AC__NO_FLAGS_SET); - assert(status >= 0); - bt=NULL; /* Make certain future references will be caught */ + HDassert(status >= 0); + bt = NULL; /* Make certain future references will be caught */ /* Advance current location in queue */ prev = cur; cur = cur->next; - } + } /* end for */ /* Free all entries from queue */ - while (head) { + while(head) { tmp = head->next; H5MM_xfree(head); head = tmp; - } + } /* end while */ FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5B_assert() */ #endif /* H5B_DEBUG */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index ddabf52..7aedd00 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -33,6 +33,7 @@ /* Other private headers needed by this file */ + /**************************/ /* Package Private Macros */ /**************************/ diff --git a/src/H5Dint.c b/src/H5Dint.c index 5d64415..85f093d 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -2233,7 +2233,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id) { H5O_t *oh = NULL; /* Pointer to dataset's object header */ diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 34ef8fb..a933c88 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -84,14 +84,14 @@ herr_t H5D_layout_version_test(hid_t did, unsigned *version) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(H5D_layout_version_test, FAIL) /* Check args */ if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(version) *version = dset->shared->layout.version; @@ -130,7 +130,7 @@ H5D_layout_contig_size_test(hid_t did, hsize_t *size) /* Check args */ if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(size) { HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index f96009c..f80bf50 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -264,7 +264,7 @@ H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr) /* Twiddle the number of open objects to avoid closing the file. */ f->nopen_objs++; if(H5O_close(ext_ptr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension") + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension") f->nopen_objs--; done: @@ -540,7 +540,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) * extension. */ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to start file's superblock extension") + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension") /* Create the Shared Object Header Message table and register it with * the metadata cache, if this file supports shared messages. diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 57d5524..f96e876 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -250,7 +250,6 @@ H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) * Purpose: Loads a fractal heap header from the disk. * * Return: Success: Pointer to a new fractal heap - * * Failure: NULL * * Programmer: Quincey Koziol diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index c16926e..dd2fd3b 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -434,9 +434,9 @@ H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr, size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, H5AC_protect_t rw) { - H5HF_parent_t par_info; /* Parent info for loading block */ - H5HF_direct_t *dblock; /* Direct block from cache */ - H5HF_direct_t *ret_value; /* Return value */ + H5HF_parent_t par_info; /* Parent info for loading block */ + H5HF_direct_t *dblock; /* Direct block from cache */ + H5HF_direct_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_protect) diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index c6e22cc..c75a28a 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1055,7 +1055,7 @@ done: /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_protect * - * Purpose: Convenience wrapper around H5AC_protect on a indirect block + * Purpose: Convenience wrapper around H5AC_protect on an indirect block * * Return: Pointer to indirect block on success, NULL on failure * @@ -1146,7 +1146,7 @@ done: /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_unprotect * - * Purpose: Convenience wrapper around H5AC_unprotect on a indirect block + * Purpose: Convenience wrapper around H5AC_unprotect on an indirect block * * Return: SUCCEED/FAIL * @@ -137,24 +137,6 @@ H5FL_BLK_DEFINE(gheap_chunk); * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer 5/26/04 - * Modified function to return the disk address of the new - * global heap collection, or HADDR_UNDEF on failure. This - * is necessary, as in some cases (i.e. flexible parallel) - * H5AC_set() will imediately flush and destroy the in memory - * version of the new collection. For the same reason, I - * moved the code which places the new collection on the cwfs - * list to just before the call to H5AC_set(). - * - * John Mainzer 6/8/05 - * Removed code setting the is_dirty field of the cache info. - * This is no longer pemitted, as the cache code is now - * manageing this field. Since this function uses a call to - * H5AC_set() (which marks the entry dirty automaticly), no - * other change is required. - * *------------------------------------------------------------------------- */ static haddr_t @@ -277,16 +259,6 @@ done: * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer, 6/8/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * - * In this case, that required adding the new heap_dirtied_ptr - * parameter to the function's argument list. - * *------------------------------------------------------------------------- */ static size_t @@ -499,30 +471,6 @@ done: * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer -- 5/24/04 - * The function used to modify the heap without protecting - * the relevant collection first. I did a half assed job - * of fixing the problem, which should hold until we try to - * support multi-threading. At that point it will have to - * be done right. - * - * See in line comment of this date for more details. - * - * John Mainzer - 5/26/04 - * Modified H5HG_create() to return the disk address of the - * new collection, instead of the address of its - * representation in core. This was necessary as in FP - * mode, the cache will immediately flush and destroy any - * entry inserted in it via H5AC_set(). I then modified - * this function to account for the change in H5HG_create(). - * - * John Mainzer - 6/8/05 - * Modified function to use the dirtied parameter of - * H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -633,7 +581,6 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/ --cwfsno; } /* end if */ } /* end else */ - HDassert(H5F_addr_defined(addr)); if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") @@ -424,8 +424,8 @@ H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr) HDassert(heap); HDassert(H5F_addr_defined(addr)); - if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, H5AC__NO_FLAGS_SET) != SUCCEED) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") + if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap") done: FUNC_LEAVE_NOAPI(ret_value) @@ -741,7 +741,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if(((fl->offset + fl->size) == heap->heap_alloc ) && ((2 * fl->size) > heap->heap_alloc )) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed") } HGOTO_DONE(SUCCEED); } @@ -750,7 +750,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if(((fl->offset + fl->size) == heap->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed") } HGOTO_DONE(SUCCEED); } else if(fl->offset + fl->size == offset) { @@ -765,7 +765,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if(((fl->offset + fl->size) == heap->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed") } /* end if */ HGOTO_DONE(SUCCEED); } /* end if */ @@ -774,7 +774,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if(((fl->offset + fl->size) == heap->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed") } /* end if */ HGOTO_DONE(SUCCEED); } /* end if */ @@ -800,7 +800,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) * Add an entry to the free list. */ if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") fl->offset = offset; fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -814,7 +814,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) if(((fl->offset + fl->size) == heap->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed") } /* end if */ done: @@ -933,11 +933,11 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) /* Get heap pointer */ if(NULL == (heap = (H5HL_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap") /* Get the total size of the local heap */ if(H5HL_size(f, heap, &local_heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to compute size of local heap") + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to compute size of local heap") /* Accumulate the size of the local heap */ *heap_size += (hsize_t)local_heap_size; diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index ab8d10a..2e8af43 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -70,7 +70,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int HDassert(indent >= 0); HDassert(fwidth >= 0); - if (NULL == (h = (H5HL_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) + if(NULL == (h = (H5HL_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") fprintf(stream, "%*sLocal Heap...\n", indent, ""); @@ -1276,8 +1276,6 @@ done: * Programmer: Quincey Koziol * Dec 7, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -2096,7 +2094,7 @@ done: ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { - ssize_t ret_value; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(H5Iget_name, FAIL) H5TRACE3("Zs", "ixz", id, name, size); @@ -569,7 +569,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_ud() */ @@ -1193,7 +1193,8 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, /* Cache object header */ if(H5AC_set(f, dxpl_id, H5AC_OHDR, oh_addr, oh, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + oh = NULL; /* Set up object location */ loc->file = f; @@ -1421,7 +1422,7 @@ int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, unsigned *oh_flags) { haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_link_oh, FAIL) @@ -1431,7 +1432,11 @@ H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, unsigned *oh_flags) /* Check for too large of an adjustment */ if((unsigned)(-adjust) > oh->nlink) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative") + + /* Adjust the link count for the object header */ oh->nlink += adjust; + + /* Mark object header as dirty in cache */ *oh_flags |= H5AC__DIRTIED_FLAG; /* Check if the object should be deleted */ @@ -1466,7 +1471,7 @@ H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, unsigned *oh_flags) /* Adjust the link count for the object header */ oh->nlink += adjust; - /* Mark the object header for deletion */ + /* Mark object header as dirty in cache */ *oh_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -1577,8 +1582,8 @@ done: H5O_t * H5O_pin(H5O_loc_t *loc, hid_t dxpl_id) { - H5O_t *oh = NULL; /* Object header */ - H5O_t *ret_value; /* Return value */ + H5O_t *oh = NULL; /* Object header */ + H5O_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_pin, NULL) @@ -1759,7 +1764,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) +H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header to modify */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 9cf50ad..13a8337 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -71,7 +71,7 @@ static unsigned H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, static htri_t H5O_move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u, hid_t dxpl_id); static htri_t H5O_move_msgs_forward(H5F_t *f, H5O_t *oh, hid_t dxpl_id); static htri_t H5O_merge_null(H5F_t *f, H5O_t *oh, hid_t dxpl_id); -static htri_t H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh, hid_t dxpl_id); +static htri_t H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static herr_t H5O_alloc_shrink_chunk(H5F_t *f, H5O_t *oh, hid_t dxpl_id, unsigned chunkno); @@ -598,7 +598,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, if(oh->mesg[u].chunkno == chunkno) { oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); - /* Flag message as dirty */ + /* Flag message as dirty directly */ oh->mesg[u].dirty = TRUE; } /* endif */ @@ -607,7 +607,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, * it's size is directly encoded in the object header) */ if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { - /* Adjust size of continuation message */ + /* Adjust size in continuation message */ HDassert(((H5O_cont_t *)(oh->mesg[u].native))->size == old_size); ((H5O_cont_t *)(oh->mesg[u].native))->size = oh->chunk[chunkno].size; @@ -1638,7 +1638,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh, hid_t dxpl_id) +H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t deleted_chunk; /* Whether to a chunk was deleted */ hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ @@ -1813,7 +1813,7 @@ H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id) rescan_header = TRUE; /* Scan for empty chunks to remove */ - result = H5O_remove_empty_chunks(f, oh, dxpl_id); + result = H5O_remove_empty_chunks(f, dxpl_id, oh); if(result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") if(result > 0) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index e0bc7d5..8bdbed5 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -730,17 +730,12 @@ done: HDfree(deleted); /* Release pointer to source object header and its derived objects */ - if(oh_src != NULL) { - /* Unprotect the source object header */ - if(H5AC_unprotect(oloc_src->file, dxpl_id, H5AC_OHDR, oloc_src->addr, oh_src, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - } /* end if */ + if(oh_src && H5AC_unprotect(oloc_src->file, dxpl_id, H5AC_OHDR, oloc_src->addr, oh_src, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Release pointer to destination object header */ - if(ret_value < 0 && oh_dst) { - if(H5O_dest(oloc_dst->file, oh_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - } /* end if */ + if(ret_value < 0 && oh_dst && H5O_dest(oloc_dst->file, oh_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") /* Release user data for particular type of object to copy */ if(udata) { diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 02379e4..4baa262 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -493,7 +493,7 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg, done: if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_read() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index df772cc..5636243 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -623,7 +623,7 @@ H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id); H5_DLL int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, unsigned *oh_flags); H5_DLL H5O_t *H5O_pin(H5O_loc_t *loc, hid_t dxpl_id); H5_DLL herr_t H5O_unpin(H5O_loc_t *loc, H5O_t *oh); -H5_DLL herr_t H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); +H5_DLL herr_t H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); H5_DLL herr_t H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS diff --git a/src/H5Sall.c b/src/H5Sall.c index 714624d..115d5d35 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -828,7 +828,7 @@ done: herr_t H5Sselect_all(hid_t spaceid) { - H5S_t *space; /* Dataspace to modify selection of */ + H5S_t *space; /* Dataspace to modify selection of */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Sselect_all, FAIL) @@ -839,7 +839,7 @@ H5Sselect_all(hid_t spaceid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Call internal routine to do the work */ - if((ret_value = H5S_select_all(space, TRUE)) < 0) + if(H5S_select_all(space, TRUE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: |