diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5HL.c | 23 | ||||
-rw-r--r-- | src/H5HLcache.c | 14 | ||||
-rwxr-xr-x | src/H5SM.c | 57 | ||||
-rw-r--r-- | src/H5SMcache.c | 22 | ||||
-rwxr-xr-x | src/H5SMpkg.h | 4 |
5 files changed, 83 insertions, 37 deletions
@@ -130,9 +130,9 @@ H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/) size_hint = H5HL_SIZEOF_FREE(f); size_hint = H5HL_ALIGN(size_hint); - /* Allocate memory structure */ + /* Allocate new heap structure */ if(NULL == (heap = H5HL_new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate new heap struct") /* Allocate file space */ total_size = heap->prfx_size + size_hint; @@ -1098,25 +1098,6 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) } /* end if */ } /* end if */ - /* Check if the heap is contiguous on disk */ - if(heap->single_cache_obj) { - /* Free the contiguous local heap in one call */ - H5_CHECK_OVERFLOW(heap->prfx_size + heap->dblk_size, size_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, addr, (hsize_t)(heap->prfx_size + heap->dblk_size)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free contiguous local heap") - } /* end if */ - else { - /* Free the local heap's prefix */ - H5_CHECK_OVERFLOW(heap->prfx_size, size_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->prfx_addr, (hsize_t)heap->prfx_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap header") - - /* Free the local heap's data block */ - H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->dblk_addr, (hsize_t)heap->dblk_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data") - } /* end else */ - /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 47d5d6f..0bccd26 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -455,7 +455,7 @@ H5HL_prefix_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, /* Should we destroy the memory version? */ if(destroy) - if(H5HL_prfx_dest(prfx) < 0) + if(H5HL_prefix_dest(f, prfx) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix") done: @@ -481,7 +481,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HL_prefix_dest(H5F_t UNUSED *f, void *thing) +H5HL_prefix_dest(H5F_t *f, void *thing) { H5HL_prfx_t *prfx = (H5HL_prfx_t *)thing; /* Local heap prefix to destroy */ herr_t ret_value = SUCCEED; /* Return value */ @@ -551,7 +551,7 @@ H5HL_prefix_clear(H5F_t UNUSED *f, void *thing, hbool_t destroy) prfx->cache_info.is_dirty = FALSE; if(destroy) - if(H5HL_prfx_dest(prfx) < 0) + if(H5HL_prefix_dest(f, prfx) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix") done: @@ -708,7 +708,7 @@ H5HL_datablock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, /* Should we destroy the memory version? */ if(destroy) - if(H5HL_dblk_dest(dblk) < 0) + if(H5HL_datablock_dest(f, dblk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block") done: @@ -730,7 +730,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HL_datablock_dest(H5F_t UNUSED *f, void *_thing) +H5HL_datablock_dest(H5F_t *f, void *_thing) { H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ herr_t ret_value = SUCCEED; /* Return value */ @@ -780,7 +780,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5HL_datablock_clear(H5F_t UNUSED *f, void *_thing, hbool_t destroy) +H5HL_datablock_clear(H5F_t *f, void *_thing, hbool_t destroy) { H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ herr_t ret_value = SUCCEED; /* Return value */ @@ -794,7 +794,7 @@ H5HL_datablock_clear(H5F_t UNUSED *f, void *_thing, hbool_t destroy) dblk->cache_info.is_dirty = FALSE; if(destroy) - if(H5HL_dblk_dest(dblk) < 0) + if(H5HL_datablock_dest(f, dblk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block") done: @@ -2291,6 +2291,63 @@ done: /*------------------------------------------------------------------------- + * Function: H5SM_table_free + * + * Purpose: Frees memory used by the SOHM table. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_table_free(H5SM_master_table_t *table) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_table_free) + + /* Sanity check */ + HDassert(table); + HDassert(table->indexes); + + H5FL_ARR_FREE(H5SM_index_header_t, table->indexes); + + H5FL_FREE(H5SM_master_table_t, table); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_table_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5SM_list_free + * + * Purpose: Frees all memory used by the list. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * November 6, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5SM_list_free(H5SM_list_t *list) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_list_free) + + HDassert(list); + HDassert(list->messages); + + H5FL_ARR_FREE(H5SM_sohm_t, list->messages); + + H5FL_FREE(H5SM_list_t, list); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5SM_list_free() */ + + +/*------------------------------------------------------------------------- * Function: H5SM_table_debug * * Purpose: Print debugging information for the master table. diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 070b00e..428cd38 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -233,7 +233,8 @@ done: if(wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_SOHM, H5E_CLOSEERROR, NULL, "can't close wrapped buffer") if(!ret_value && table) - (void)H5SM_table_dest(f, table); + if(H5SM_table_free(table) < 0) + HDONE_ERROR(H5E_SOHM, H5E_CANTFREE, NULL, "unable to destroy sohm table") FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_table_load() */ @@ -366,17 +367,20 @@ done: static herr_t H5SM_table_dest(H5F_t UNUSED *f, H5SM_master_table_t* table) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_table_dest) + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5SM_table_dest) /* Sanity check */ HDassert(table); HDassert(table->indexes); - H5FL_ARR_FREE(H5SM_index_header_t, table->indexes); + /* Destroy Shared Object Header Message table */ + if(H5SM_table_free(table) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message table") - (void)H5FL_FREE(H5SM_master_table_t, table); - - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SM_table_dest() */ @@ -681,9 +685,9 @@ H5SM_list_dest(H5F_t *f, H5SM_list_t* list) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, FAIL, "unable to free shared message list") } /* end if */ - /* Release resources */ - H5FL_ARR_FREE(H5SM_sohm_t, list->messages); - (void)H5FL_FREE(H5SM_list_t, list); + /* Destroy Shared Object Header Message list */ + if(H5SM_list_free(list) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTRELEASE, FAIL, "unable to free shared message list") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index 64f0ccb..b023c97 100755 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -251,6 +251,10 @@ H5_DLL herr_t H5SM_bt2_convert_to_list_op(const void * record, void *op_data); /* Fractal heap 'op' callback to compute hash value for message "in place" */ H5_DLL herr_t H5SM_get_hash_fh_cb(const void *obj, size_t obj_len, void *_udata); +/* Routines to release data structures */ +herr_t H5SM_table_free(H5SM_master_table_t *table); +herr_t H5SM_list_free(H5SM_list_t *list); + /* Testing functions */ #ifdef H5SM_TESTING H5_DLL herr_t H5SM_get_mesg_count_test(H5F_t *f, hid_t dxpl_id, unsigned type_id, |