summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Gcache.c9
-rw-r--r--src/H5Gnode.c34
-rw-r--r--src/H5Gpkg.h1
-rw-r--r--src/H5HFcache.c60
-rw-r--r--src/H5HFdblock.c47
-rw-r--r--src/H5HFhdr.c13
-rw-r--r--src/H5HFiblock.c53
-rw-r--r--src/H5HFpkg.h8
8 files changed, 167 insertions, 58 deletions
diff --git a/src/H5Gcache.c b/src/H5Gcache.c
index a5805e3..7b4532d 100644
--- a/src/H5Gcache.c
+++ b/src/H5Gcache.c
@@ -197,7 +197,7 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value)
- if(sym && H5G_node_dest(f, sym) < 0)
+ if(sym && H5G_node_free(sym) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, NULL, "unable to destroy symbol table node")
FUNC_LEAVE_NOAPI(ret_value)
@@ -339,10 +339,9 @@ H5G_node_dest(H5F_t *f, H5G_node_t *sym)
HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to free symbol table node")
} /* end if */
- /* Release resources */
- if(sym->entry)
- sym->entry = (H5G_entry_t *)H5FL_SEQ_FREE(H5G_entry_t, sym->entry);
- sym = H5FL_FREE(H5G_node_t, sym);
+ /* Destroy symbol table node */
+ if(H5G_node_free(sym) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to destroy symbol table node")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index c65d988..3c07313 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -263,6 +263,40 @@ H5G_node_size_real(const H5F_t *f)
/*-------------------------------------------------------------------------
+ * Function: H5G_node_free
+ *
+ * Purpose: Destroy a symbol table node in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Jan 15 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_node_free(H5G_node_t *sym)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_node_free)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(sym);
+
+ /* Verify that node is clean */
+ HDassert(sym->cache_info.is_dirty == FALSE);
+
+ if(sym->entry)
+ sym->entry = H5FL_SEQ_FREE(H5G_entry_t, sym->entry);
+ sym = H5FL_FREE(H5G_node_t, sym);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5G_node_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_node_create
*
* Purpose: Creates a new empty symbol table node. This function is
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 652a6e1..15e9254 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -448,6 +448,7 @@ H5_DLL int H5G_node_build_table(H5F_t *f, hid_t dxpl_id, const void *_lt_key, ha
const void *_rt_key, void *_udata);
H5_DLL herr_t H5G_node_iterate_size(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr,
const void *_rt_key, void *_udata);
+H5_DLL herr_t H5G_node_free(H5G_node_t *sym);
/* Functions that understand links in groups */
H5_DLL int H5G_link_cmp_name_inc(const void *lnk1, const void *lnk2);
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index 4251f94..f1babd4 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -80,14 +80,17 @@ static herr_t H5HF_dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dt
/* Metadata cache (H5AC) callbacks */
static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr, unsigned UNUSED * flags_ptr);
+static herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr);
static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_hdr_t *hdr, hbool_t destroy);
static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_hdr_t *hdr, size_t *size_ptr);
static H5HF_indirect_t *H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
static herr_t H5HF_cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_indirect_t *iblock, unsigned UNUSED * flags_ptr);
+static herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock);
static herr_t H5HF_cache_iblock_clear(H5F_t *f, H5HF_indirect_t *iblock, hbool_t destroy);
static herr_t H5HF_cache_iblock_size(const H5F_t *f, const H5HF_indirect_t *iblock, size_t *size_ptr);
static H5HF_direct_t *H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
static herr_t H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_direct_t *dblock, unsigned UNUSED * flags_ptr);
+static herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock);
static herr_t H5HF_cache_dblock_clear(H5F_t *f, H5HF_direct_t *dblock, hbool_t destroy);
static herr_t H5HF_cache_dblock_size(const H5F_t *f, const H5HF_direct_t *dblock, size_t *size_ptr);
@@ -578,7 +581,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -605,6 +608,7 @@ H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr)
/* Free the shared info itself */
if(H5HF_hdr_free(hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "unable to release fractal heap header")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_cache_hdr_dest() */
@@ -864,7 +868,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
/* Allocate & initialize child indirect block pointer array */
if(NULL == (iblock->child_iblocks = H5FL_SEQ_CALLOC(H5HF_indirect_ptr_t, (size_t)(indir_rows * hdr->man_dtable.cparam.width))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block entries")
+ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for block entries")
} /* end if */
else
iblock->child_iblocks = NULL;
@@ -877,7 +881,8 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && iblock)
- (void)H5HF_cache_iblock_dest(f, iblock);
+ if(H5HF_man_iblock_dest(iblock) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap indirect block")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_cache_iblock_load() */
@@ -1083,7 +1088,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1112,26 +1117,9 @@ H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock)
} /* end if */
} /* end if */
- /* Set the shared heap header's file context for this operation */
- iblock->hdr->f = f;
-
- /* Decrement reference count on shared info */
- if(H5HF_hdr_decr(iblock->hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
- if(iblock->parent)
- if(H5HF_iblock_decr(iblock->parent) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
-
- /* Release entry tables */
- if(iblock->ents)
- (void)H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents);
- if(iblock->filt_ents)
- (void)H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents);
- if(iblock->child_iblocks)
- (void)H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks);
-
- /* Free fractal heap indirect block info */
- (void)H5FL_FREE(H5HF_indirect_t, iblock);
+ /* Destroy fractal heap indirect block */
+ if(H5HF_man_iblock_dest(iblock) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1376,7 +1364,8 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
done:
if(!ret_value && dblock)
- (void)H5HF_cache_dblock_dest(f, dblock);
+ if(H5HF_man_dblock_dest(dblock) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "unable to destroy fractal heap direct block")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_cache_dblock_load() */
@@ -1668,7 +1657,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1698,22 +1687,9 @@ H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock)
} /* end if */
} /* end if */
- /* Set the shared heap header's file context for this operation */
- dblock->hdr->f = f;
-
- /* Decrement reference count on shared fractal heap info */
- HDassert(dblock->hdr);
- if(H5HF_hdr_decr(dblock->hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
- if(dblock->parent)
- if(H5HF_iblock_decr(dblock->parent) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
-
- /* Free block's buffer */
- dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk);
-
- /* Free fractal heap direct block info */
- (void)H5FL_FREE(H5HF_direct_t, dblock);
+ /* Destroy fractal heap direct block */
+ if(H5HF_man_dblock_dest(dblock) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c
index cde747c..8f27bfe 100644
--- a/src/H5HFdblock.c
+++ b/src/H5HFdblock.c
@@ -197,7 +197,8 @@ HDmemset(dblock->blk, 0, dblock->size);
done:
if(ret_value < 0)
if(dblock)
- (void)H5HF_cache_dblock_dest(hdr->f, dblock);
+ if(H5HF_man_dblock_dest(dblock) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap direct block")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_dblock_create() */
@@ -641,3 +642,47 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_dblock_delete() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_man_dblock_dest
+ *
+ * Purpose: Destroys a fractal heap direct block in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 27 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_man_dblock_dest(H5HF_direct_t *dblock)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(dblock);
+
+ /* Decrement reference count on shared fractal heap info */
+ HDassert(dblock->hdr != NULL);
+ if(H5HF_hdr_decr(dblock->hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
+ if(dblock->parent)
+ if(H5HF_iblock_decr(dblock->parent) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
+
+ /* Free block's buffer */
+ dblock->blk = H5FL_BLK_FREE(direct_block, dblock->blk);
+
+ /* Free fractal heap direct block info */
+ dblock = H5FL_FREE(H5HF_direct_t, dblock);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_man_dblock_dest() */
+
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c
index e55f472..468f9c2 100644
--- a/src/H5HFhdr.c
+++ b/src/H5HFhdr.c
@@ -1343,7 +1343,9 @@ done:
herr_t
H5HF_hdr_free(H5HF_hdr_t *hdr)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_free)
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_free)
/*
* Check arguments.
@@ -1351,16 +1353,19 @@ H5HF_hdr_free(H5HF_hdr_t *hdr)
HDassert(hdr);
/* Free the block size lookup table for the doubling table */
- H5HF_dtable_dest(&hdr->man_dtable);
+ if(H5HF_dtable_dest(&hdr->man_dtable) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap doubling table")
/* Release any I/O pipeline filter information */
if(hdr->pline.nused)
- H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline));
+ if(H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline)) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to reset I/O pipeline message")
/* Free the shared info itself */
hdr = H5FL_FREE(H5HF_hdr_t, hdr);
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_free() */
diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c
index 6fa8b42..66b6390 100644
--- a/src/H5HFiblock.c
+++ b/src/H5HFiblock.c
@@ -1046,7 +1046,8 @@ H5HF_man_iblock_create(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *par_iblo
done:
if(ret_value < 0)
if(iblock)
- (void)H5HF_cache_iblock_dest(hdr->f, iblock);
+ if(H5HF_man_iblock_dest(iblock) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy fractal heap indirect block")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_iblock_create() */
@@ -1557,3 +1558,53 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_man_iblock_size() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_man_iblock_dest
+ *
+ * Purpose: Destroys a fractal heap indirect block in memory.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 6 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_man_iblock_dest(H5HF_indirect_t *iblock)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_iblock_dest)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(iblock);
+ HDassert(iblock->rc == 0);
+
+ /* Decrement reference count on shared info */
+ HDassert(iblock->hdr);
+ if(H5HF_hdr_decr(iblock->hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
+ if(iblock->parent)
+ if(H5HF_iblock_decr(iblock->parent) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")
+
+ /* Release entry tables */
+ if(iblock->ents)
+ H5FL_SEQ_FREE(H5HF_indirect_ent_t, iblock->ents);
+ if(iblock->filt_ents)
+ H5FL_SEQ_FREE(H5HF_indirect_filt_ent_t, iblock->filt_ents);
+ if(iblock->child_iblocks)
+ H5FL_SEQ_FREE(H5HF_indirect_ptr_t, iblock->child_iblocks);
+
+ /* Free fractal heap indirect block info */
+ iblock = H5FL_FREE(H5HF_indirect_t, iblock);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5HF_man_iblock_dest() */
+
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 44577f4..be52dcd 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -564,6 +564,7 @@ H5_DLL herr_t H5HF_hdr_reset_iter(H5HF_hdr_t *hdr, hsize_t curr_off);
H5_DLL herr_t H5HF_hdr_empty(H5HF_hdr_t *hdr);
H5_DLL herr_t H5HF_hdr_free(H5HF_hdr_t *hdr);
H5_DLL herr_t H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id);
+H5_DLL herr_t H5HF_hdr_dest(H5HF_hdr_t *hdr);
/* Indirect block routines */
H5_DLL herr_t H5HF_iblock_incr(H5HF_indirect_t *iblock);
@@ -594,6 +595,7 @@ H5_DLL herr_t H5HF_man_iblock_delete(H5HF_hdr_t *hdr, hid_t dxpl_id,
unsigned par_entry);
H5_DLL herr_t H5HF_man_iblock_size(H5F_t *f, hid_t dxpl_id, H5HF_hdr_t *hdr,
haddr_t iblock_addr, unsigned nrows, H5HF_indirect_t *par_iblock, unsigned par_entry, hsize_t *heap_size/*out*/);
+H5_DLL herr_t H5HF_man_iblock_dest(H5HF_indirect_t *iblock);
/* Direct block routines */
H5_DLL herr_t H5HF_man_dblock_new(H5HF_hdr_t *fh, hid_t dxpl_id, size_t request,
@@ -612,6 +614,7 @@ H5_DLL herr_t H5HF_man_dblock_locate(H5HF_hdr_t *hdr, hid_t dxpl_id,
unsigned *par_entry, hbool_t *par_did_protect, H5AC_protect_t rw);
H5_DLL herr_t H5HF_man_dblock_delete(H5F_t *f, hid_t dxpl_id, haddr_t dblock_addr,
hsize_t dblock_size);
+H5_DLL herr_t H5HF_man_dblock_dest(H5HF_direct_t *dblock);
/* Managed object routines */
H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size,
@@ -660,11 +663,6 @@ H5_DLL herr_t H5HF_tiny_op(H5HF_hdr_t *hdr, const uint8_t *id,
H5HF_operator_t op, void *op_data);
H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id);
-/* Metadata cache callbacks */
-H5_DLL herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr);
-H5_DLL herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock);
-H5_DLL herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock);
-
/* Debugging routines for dumping file structures */
H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth);