diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-01 18:59:43 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-01 18:59:43 (GMT) |
commit | 3a3e9753e61f467f27ac32d15d782faee4b85870 (patch) | |
tree | b9378648848620bdf87ce3588bdc5503aab0129e /src/H5B2int.c | |
parent | c424f8017e4556609dcd0e1c9f63fa5250db58b0 (diff) | |
download | hdf5-3a3e9753e61f467f27ac32d15d782faee4b85870.zip hdf5-3a3e9753e61f467f27ac32d15d782faee4b85870.tar.gz hdf5-3a3e9753e61f467f27ac32d15d782faee4b85870.tar.bz2 |
[svn-r18490] Description:
Cleanups & renamings for extracted data structure 'destroy' routines.
Tested on:
Mac OS X/32 10.6.3 (amazon) w/debug, production & parallel
(h5commit not required on this branch)
Diffstat (limited to 'src/H5B2int.c')
-rw-r--r-- | src/H5B2int.c | 132 |
1 files changed, 130 insertions, 2 deletions
diff --git a/src/H5B2int.c b/src/H5B2int.c index c9eb628..e132169 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -2030,7 +2030,8 @@ HDmemset(leaf->leaf_native, 0, shared->type->nrec_size * shared->node_info[0].ma done: if(ret_value < 0) { if(leaf) - (void)H5B2_cache_leaf_dest(leaf); + if(H5B2_leaf_dest(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2111,7 +2112,8 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (shared->node_info[de done: if(ret_value < 0) { if(internal) - (void)H5B2_cache_internal_dest(internal); + if(H5B2_internal_dest(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -3304,6 +3306,132 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate_size_node() */ + +/*------------------------------------------------------------------------- + * Function: H5B2_hdr_dest + * + * Purpose: Destroys a B-tree header in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 1 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_hdr_dest(H5B2_t *bt2) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_hdr_dest) + + /* + * Check arguments. + */ + HDassert(bt2); + + /* Decrement reference count on shared B-tree info */ + if(bt2->shared) + H5RC_DEC(bt2->shared); + + /* Free B-tree header info */ + bt2 = H5FL_FREE(H5B2_t, bt2); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_hdr_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_internal_dest + * + * Purpose: Destroys a B-tree internal node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_internal_dest(H5B2_internal_t *internal) +{ + H5B2_shared_t *shared; /* Shared B-tree information */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_internal_dest) + + /* + * Check arguments. + */ + HDassert(internal); + + /* Get the pointer to the shared B-tree info */ + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + HDassert(shared); + + /* Release internal node's native key buffer */ + if(internal->int_native) + H5FL_FAC_FREE(shared->node_info[internal->depth].nat_rec_fac, internal->int_native); + + /* Release internal node's node pointer buffer */ + if(internal->node_ptrs) + H5FL_FAC_FREE(shared->node_info[internal->depth].node_ptr_fac, internal->node_ptrs); + + /* Decrement reference count on shared B-tree info */ + if(internal->shared) + H5RC_DEC(internal->shared); + + /* Free B-tree internal node info */ + internal = H5FL_FREE(H5B2_internal_t, internal); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_internal_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_leaf_dest + * + * Purpose: Destroys a B-tree leaf node in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Feb 2 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_leaf_dest(H5B2_leaf_t *leaf) +{ + H5B2_shared_t *shared; /* Shared B-tree information */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_leaf_dest) + + /* + * Check arguments. + */ + HDassert(leaf); + + /* Get the pointer to the shared B-tree info */ + shared = (H5B2_shared_t *)H5RC_GET_OBJ(leaf->shared); + HDassert(shared); + + /* Release leaf's native key buffer */ + if(leaf->leaf_native) + H5FL_FAC_FREE(shared->node_info[0].nat_rec_fac, leaf->leaf_native); + + /* Decrement reference count on shared B-tree info */ + if(leaf->shared) + H5RC_DEC(leaf->shared); + + /* Free B-tree leaf node info */ + leaf = H5FL_FREE(H5B2_leaf_t, leaf); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5B2_leaf_dest() */ + #ifdef H5B2_DEBUG /*------------------------------------------------------------------------- |