From 3a3e9753e61f467f27ac32d15d782faee4b85870 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 1 Apr 2010 13:59:43 -0500 Subject: [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) --- src/H5B.c | 14 +++--- src/H5B2.c | 132 +------------------------------------------------------- src/H5B2cache.c | 43 ++++++++++++------ src/H5B2int.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/H5B2pkg.h | 8 ++-- src/H5Bcache.c | 13 ++++-- src/H5Bpkg.h | 2 +- src/H5FS.c | 28 ++++++------ src/H5FScache.c | 34 +++++++++------ src/H5FSpkg.h | 6 +-- 10 files changed, 222 insertions(+), 190 deletions(-) diff --git a/src/H5B.c b/src/H5B.c index e3c7314..76e2f04 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -261,7 +261,9 @@ done: (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode); } /* end if */ if(bt) - (void)H5B_dest(bt); + /* Destroy B-tree node */ + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2045,9 +2047,9 @@ done: /*------------------------------------------------------------------------- - * Function: H5B_dest + * Function: H5B_node_dest * - * Purpose: Destroy/release an "in core representation" of a B-tree node + * Purpose: Destroy/release a B-tree node * * Return: Success: SUCCEED * Failure: FAIL @@ -2059,9 +2061,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B_dest(H5B_t *bt) +H5B_node_dest(H5B_t *bt) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_node_dest) /* check arguments */ HDassert(bt); @@ -2073,7 +2075,7 @@ H5B_dest(H5B_t *bt) bt = H5FL_FREE(H5B_t, bt); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5B_dest() */ +} /* end H5B_node_dest() */ /*------------------------------------------------------------------------- diff --git a/src/H5B2.c b/src/H5B2.c index c2114eb..bf38fd4 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -143,7 +143,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, done: if(ret_value < 0) { if(bt2) - (void)H5B2_cache_hdr_dest(bt2); + if(H5B2_hdr_dest(bt2) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header node") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1327,132 +1328,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate_size() */ - -/*------------------------------------------------------------------------- - * Function: H5B2_cache_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 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5B2_cache_hdr_dest(H5B2_t *bt2) -{ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_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 */ - H5FL_FREE(H5B2_t, bt2); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5B2_cache_hdr_dest() */ - - -/*------------------------------------------------------------------------- - * Function: H5B2_cache_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 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5B2_cache_internal_dest(H5B2_internal_t *internal) -{ - H5B2_shared_t *shared; /* Shared B-tree information */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_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 */ - H5FL_FREE(H5B2_internal_t, internal); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5B2_cache_internal_dest() */ - - -/*------------------------------------------------------------------------- - * Function: H5B2_cache_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 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5B2_cache_leaf_dest(H5B2_leaf_t *leaf) -{ - H5B2_shared_t *shared; /* Shared B-tree information */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_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 */ - H5FL_FREE(H5B2_leaf_t,leaf); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5B2_cache_leaf_dest() */ - diff --git a/src/H5B2cache.c b/src/H5B2cache.c index aac486c..67493f8 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -236,7 +236,8 @@ H5B2_cache_hdr_deserialize(haddr_t UNUSED addr, size_t UNUSED len, done: if(!ret_value && bt2) - (void)H5B2_cache_hdr_dest(bt2); + if(H5B2_hdr_dest(bt2) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree header node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_cache_hdr_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -348,15 +349,19 @@ H5B2_cache_hdr_serialize(const H5F_t *f, hid_t UNUSED dxpl_id, static herr_t H5B2_cache_hdr_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_hdr_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_hdr_free_icr) /* Check arguments */ HDassert(thing); /* Destroy v2 b-tree header */ - H5B2_cache_hdr_dest(thing); + if(H5B2_hdr_dest(thing) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree header node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_hdr_free_icr() */ @@ -480,7 +485,8 @@ H5B2_cache_internal_deserialize(haddr_t UNUSED addr, size_t UNUSED len, done: if(!ret_value && internal) - (void)H5B2_cache_internal_dest(internal); + if(H5B2_internal_dest(internal) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_internal_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -598,15 +604,19 @@ done: static herr_t H5B2_cache_internal_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_internal_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_internal_free_icr) /* Check arguments */ HDassert(thing); - /* Destroy v2 b-tree header */ - H5B2_cache_internal_dest(thing); + /* Destroy v2 b-tree internal node */ + if(H5B2_internal_dest(thing) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree internal node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_internal_free_icr() */ @@ -711,7 +721,8 @@ H5B2_cache_leaf_deserialize(haddr_t UNUSED addr, size_t UNUSED len, done: if(!ret_value && leaf) - (void)H5B2_cache_leaf_dest(leaf); + if(H5B2_leaf_dest(leaf) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_leaf_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -815,14 +826,18 @@ done: static herr_t H5B2_cache_leaf_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B2_cache_leaf_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B2_cache_leaf_free_icr) /* Check arguments */ HDassert(thing); - /* Destroy v2 b-tree header */ - H5B2_cache_leaf_dest(thing); + /* Destroy v2 b-tree leaf node */ + if(H5B2_leaf_dest(thing) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree leaf node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_leaf_free_icr() */ 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 /*------------------------------------------------------------------------- diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 95c10e3..5ffa062 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -324,10 +324,10 @@ H5_DLL herr_t H5B2_delete_node(H5F_t *f, hid_t dxpl_id, H5RC_t *bt2_shared, unsigned depth, const H5B2_node_ptr_t *curr_node, H5B2_remove_t op, void *op_data); -/* Metadata cache callbacks */ -H5_DLL herr_t H5B2_cache_hdr_dest(H5B2_t *b); -H5_DLL herr_t H5B2_cache_leaf_dest(H5B2_leaf_t *l); -H5_DLL herr_t H5B2_cache_internal_dest(H5B2_internal_t *i); +/* Routines for destroying structures */ +H5_DLL herr_t H5B2_hdr_dest(H5B2_t *b); +H5_DLL herr_t H5B2_leaf_dest(H5B2_leaf_t *l); +H5_DLL herr_t H5B2_internal_dest(H5B2_internal_t *i); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, diff --git a/src/H5Bcache.c b/src/H5Bcache.c index fd99d1f..26299b0 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -182,7 +182,8 @@ H5B_deserialize(haddr_t UNUSED addr, size_t UNUSED len, const void *image, done: if(!ret_value && bt) - (void)H5B_dest(bt); + if(H5B_node_dest(bt) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to destroy B-tree node") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_deserialize() */ @@ -287,14 +288,18 @@ done: static herr_t H5B_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5B_free_icr) /* Check arguments */ HDassert(thing); /* Destroy B-tree node */ - H5B_dest(thing); + if(H5B_node_dest(thing) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_free_icr() */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index a1fe17e..e48ec23 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -85,7 +85,7 @@ H5FL_EXTERN(H5B_t); /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5B_dest(H5B_t *bt); +H5_DLL herr_t H5B_node_dest(H5B_t *bt); #endif /*_H5Bpkg_H*/ diff --git a/src/H5FS.c b/src/H5FS.c index 89817d0..3e6796a 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -144,7 +144,8 @@ HDfprintf(stderr, "%s: Creating free space manager, nclasses = %Zu\n", FUNC, ncl done: if(!ret_value && fspace) - (void)H5FS_cache_hdr_dest(fspace); + if(H5FS_hdr_dest(fspace) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_create() */ @@ -512,7 +513,7 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) /*------------------------------------------------------------------------- - * Function: H5FS_cache_hdr_dest + * Function: H5FS_hdr_dest * * Purpose: Destroys a free space header in memory. * @@ -524,14 +525,13 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ herr_t -H5FS_cache_hdr_dest(H5FS_t *fspace) +H5FS_hdr_dest(H5FS_t *fspace) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_hdr_dest) + FUNC_ENTER_NOAPI_NOINIT(H5FS_hdr_dest) /* * Check arguments. @@ -545,16 +545,17 @@ H5FS_cache_hdr_dest(H5FS_t *fspace) if((fspace->sect_cls[u].term_cls)(&fspace->sect_cls[u]) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "unable to finalize section class") } /* end for */ + /* Release the memory for the free space section classes */ if(fspace->sect_cls) fspace->sect_cls = H5FL_SEQ_FREE(H5FS_section_class_t, fspace->sect_cls); /* Free free space info */ - H5FL_FREE(H5FS_t, fspace); + fspace = H5FL_FREE(H5FS_t, fspace); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS_cache_hdr_dest() */ +} /* end H5FS_hdr_dest() */ /*------------------------------------------------------------------------- @@ -616,14 +617,14 @@ H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data) H5SL_destroy(fspace_node->sect_list, H5FS_sinfo_free_sect_cb, op_data); /* Release free space list node */ - H5FL_FREE(H5FS_node_t, fspace_node); + fspace_node = H5FL_FREE(H5FS_node_t, fspace_node); FUNC_LEAVE_NOAPI(0) } /* H5FS_sinfo_free_node_cb() */ /*------------------------------------------------------------------------- - * Function: H5FS_cache_sinfo_dest + * Function: H5FS_sinfo_dest * * Purpose: Destroys a free space section info in memory. * @@ -635,14 +636,13 @@ H5FS_sinfo_free_node_cb(void *item, void UNUSED *key, void *op_data) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ herr_t -H5FS_cache_sinfo_dest(H5FS_sinfo_t *sinfo) +H5FS_sinfo_dest(H5FS_sinfo_t *sinfo) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_dest) + FUNC_ENTER_NOAPI_NOINIT(H5FS_sinfo_dest) /* * Check arguments. @@ -674,11 +674,11 @@ H5FS_cache_sinfo_dest(H5FS_sinfo_t *sinfo) HGOTO_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin free space header") /* Release free space section info */ - H5FL_FREE(H5FS_sinfo_t, sinfo); + sinfo = H5FL_FREE(H5FS_sinfo_t, sinfo); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FS_cache_sinfo_dest() */ +} /* end H5FS_sinfo_dest() */ #ifdef H5FS_DEBUG diff --git a/src/H5FScache.c b/src/H5FScache.c index 234e639..afce7f1 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -103,7 +103,7 @@ const H5AC_class_t H5AC_FSPACE_HDR[1] = {{ NULL, /* H5FS_cache_hdr_image_len, */ H5FS_cache_hdr_serialize, H5FS_cache_hdr_free_icr, - NULL, /* H5FS_cache_hdr_clear_dirty_bits, */ + NULL, }}; /* H5FS serialized sections inherit cache-like properties from H5AC */ @@ -236,7 +236,7 @@ H5FS_cache_hdr_deserialize(haddr_t UNUSED addr, size_t UNUSED len, /* Verify checksum */ if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") + HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") /* Sanity check */ HDassert((size_t)(p - (const uint8_t *)image) <= len); @@ -247,7 +247,8 @@ H5FS_cache_hdr_deserialize(haddr_t UNUSED addr, size_t UNUSED len, done: /* Release resources */ if(!ret_value && fspace) - (void)H5FS_cache_hdr_dest(fspace); + if(H5FS_hdr_dest(fspace) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_cache_hdr_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -369,15 +370,19 @@ H5FS_cache_hdr_serialize(const H5F_t *f, hid_t UNUSED dxpl_id, static herr_t H5FS_cache_hdr_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_cache_hdr_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_hdr_free_icr) /* Check arguments */ HDassert(thing); /* Destroy free space header */ - H5FS_cache_hdr_dest(thing); + if(H5FS_hdr_dest(thing) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space header") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_cache_hdr_free_icr() */ @@ -528,7 +533,7 @@ H5FS_cache_sinfo_deserialize(haddr_t UNUSED addr, size_t UNUSED len, /* Verify checksum */ if(stored_chksum != computed_chksum) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") + HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block") /* Sanity check */ HDassert((size_t)(p - (const uint8_t *)image) <= len); @@ -538,7 +543,8 @@ H5FS_cache_sinfo_deserialize(haddr_t UNUSED addr, size_t UNUSED len, done: if(!ret_value && sinfo) - (void)H5FS_cache_sinfo_dest(sinfo); + if(H5FS_sinfo_dest(sinfo) < 0) + HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_cache_sinfo_deserialize() */ /*lint !e818 Can't make udata a pointer to const */ @@ -751,14 +757,18 @@ done: static herr_t H5FS_cache_sinfo_free_icr(haddr_t UNUSED addr, size_t UNUSED len, void *thing) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FS_cache_sinfo_free_icr) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_free_icr) /* Check arguments */ HDassert(thing); - /* Destroy B-tree node */ - H5FS_cache_sinfo_dest(thing); + /* Destroy free space info */ + if(H5FS_sinfo_dest(thing) < 0) + HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "unable to destroy free space info") - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_cache_sinfo_free_icr() */ diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index ece1964..4cf20de 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -227,9 +227,9 @@ H5_DLL herr_t H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5_DLL herr_t H5FS_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr); -/* Metadata cache callbacks */ -H5_DLL herr_t H5FS_cache_hdr_dest(H5FS_t *hdr); -H5_DLL herr_t H5FS_cache_sinfo_dest(H5FS_sinfo_t *sinfo); +/* Routines for destroying structures */ +H5_DLL herr_t H5FS_hdr_dest(H5FS_t *hdr); +H5_DLL herr_t H5FS_sinfo_dest(H5FS_sinfo_t *sinfo); /* Sanity check routines */ #ifdef H5FS_DEBUG -- cgit v0.12