summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-10-27 19:18:45 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-10-27 19:18:45 (GMT)
commitab3f3e0219d80b5407fe5da785a7faae443c7ffc (patch)
treec51c1dc909d9b5e82f077620ca4fc423a5d1edd4 /src
parent4af649f03d3eb2826616c6f730bc4281c027a536 (diff)
downloadhdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.zip
hdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.tar.gz
hdf5-ab3f3e0219d80b5407fe5da785a7faae443c7ffc.tar.bz2
[svn-r17749] Description:
Refactor v2 B-tree code to bring it further in line with how the fractal heap code works, to make forthcoming modificaions easier. Also minor tweaks to the fractal heap code to clean it up a bit more also. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5B2.c41
-rw-r--r--src/H5B2cache.c15
-rw-r--r--src/H5B2hdr.c163
-rw-r--r--src/H5B2pkg.h12
-rw-r--r--src/H5HF.c14
-rw-r--r--src/H5HFcache.c14
-rw-r--r--src/H5HFhdr.c63
-rw-r--r--src/H5HFpkg.h4
8 files changed, 212 insertions, 114 deletions
diff --git a/src/H5B2.c b/src/H5B2.c
index e15c11e..6408dc4 100644
--- a/src/H5B2.c
+++ b/src/H5B2.c
@@ -41,7 +41,6 @@
#include "H5private.h" /* Generic Functions */
#include "H5B2pkg.h" /* v2 B-trees */
#include "H5Eprivate.h" /* Error handling */
-#include "H5MFprivate.h" /* File memory management */
/****************/
@@ -71,9 +70,6 @@ static herr_t H5B2_close(H5B2_hdr_t *hdr, hid_t dxpl_id);
/* Package Variables */
/*********************/
-/* Declare a free list to manage the H5B2_hdr_t struct */
-H5FL_DEFINE(H5B2_hdr_t);
-
/*****************************/
/* Library Private Variables */
@@ -103,7 +99,7 @@ herr_t
H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam,
haddr_t *addr_p)
{
- H5B2_hdr_t *hdr = NULL; /* The new B-tree header information */
+ haddr_t hdr_addr; /* The new v2 B-tree header address */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B2_create, FAIL)
@@ -115,36 +111,14 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam,
HDassert(cparam);
HDassert(addr_p);
- /*
- * Allocate file and memory data structures.
- */
- if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree header")
-
- /* Assign non-zero information */
- hdr->root.addr = HADDR_UNDEF;
-
- /* Initialize shared B-tree info */
- if(H5B2_hdr_init(f, hdr, cparam, 0) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create shared B-tree info")
-
- /* Allocate space for the header on disk */
- if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)H5B2_HEADER_SIZE(f))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree header")
-
- /* Cache the new B-tree node */
- if(H5AC_set(f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree header to cache")
+ /* Create shared v2 B-tree header */
+ if(HADDR_UNDEF == (hdr_addr = H5B2_hdr_create(f, dxpl_id, cparam)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't create v2 B-tree header")
/* Set the B-tree's address to return */
- *addr_p = hdr->addr;
+ *addr_p = hdr_addr;
done:
- if(ret_value < 0) {
- if(hdr)
- (void)H5B2_cache_hdr_dest(f, hdr);
- } /* end if */
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B2_create() */
@@ -188,10 +162,9 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, const H5B2_class_t *type, haddr_t addr,
ret_value = hdr;
done:
- if(!ret_value) {
- if(hdr && H5B2_close(hdr, dxpl_id) < 0)
+ if(!ret_value && hdr)
+ if(H5B2_close(hdr, dxpl_id) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTCLOSEOBJ, NULL, "unable to close B-tree")
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5B2_open() */
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index ffb2995..859554e 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -170,9 +170,8 @@ H5B2_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_cls, voi
HDassert(cls);
/* Allocate new B-tree header and reset cache info */
- if(NULL == (hdr = H5FL_MALLOC(H5B2_hdr_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- HDmemset(&hdr->cache_info, 0, sizeof(H5AC_info_t));
+ if(NULL == (hdr = H5B2_hdr_alloc()))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "allocation failed for B-tree header")
/* Wrap the local buffer for serialized header info */
if(NULL == (wb = H5WB_wrap(hdr_buf, sizeof(hdr_buf))))
@@ -252,7 +251,8 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && hdr)
- (void)H5B2_cache_hdr_dest(f, hdr);
+ if(H5B2_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, NULL, "can't release v2 B-tree header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B2_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -407,9 +407,6 @@ H5B2_cache_hdr_dest(H5F_t *f, H5B2_hdr_t *hdr)
if(H5B2_hdr_free(hdr) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free v2 B-tree header info")
- /* Free B-tree header info */
- (void)H5FL_FREE(H5B2_hdr_t, hdr);
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B2_cache_hdr_dest() */
@@ -763,7 +760,7 @@ H5B2_cache_internal_dest(H5F_t *f, H5B2_internal_t *internal)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header")
/* Free B-tree internal node info */
- H5FL_FREE(H5B2_internal_t, internal);
+ internal = H5FL_FREE(H5B2_internal_t, internal);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1081,7 +1078,7 @@ H5B2_cache_leaf_dest(H5F_t *f, H5B2_leaf_t *leaf)
HGOTO_ERROR(H5E_BTREE, H5E_CANTDEC, FAIL, "can't decrement ref. count on B-tree header")
/* Free B-tree leaf node info */
- H5FL_FREE(H5B2_leaf_t, leaf);
+ leaf = H5FL_FREE(H5B2_leaf_t, leaf);
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c
index ef57186..489d047 100644
--- a/src/H5B2hdr.c
+++ b/src/H5B2hdr.c
@@ -79,6 +79,9 @@
/* Local Variables */
/*******************/
+/* Declare a free list to manage the H5B2_hdr_t struct */
+H5FL_DEFINE_STATIC(H5B2_hdr_t);
+
/* Declare a free list to manage B-tree node pages to/from disk */
H5FL_BLK_DEFINE_STATIC(node_page);
@@ -214,57 +217,98 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5B2_hdr_free
+ * Function: H5B2_hdr_alloc
*
- * Purpose: Free B-tree header info
+ * Purpose: Allocate B-tree header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 27 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+H5B2_hdr_t *
+H5B2_hdr_alloc(void)
+{
+ H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */
+ H5B2_hdr_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_alloc)
+
+ /* Allocate space for the shared information */
+ if(NULL == (hdr = H5FL_CALLOC(H5B2_hdr_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree header")
+
+ /* Assign non-zero information */
+ hdr->root.addr = HADDR_UNDEF;
+
+ /* Set return value */
+ ret_value = hdr;
+
+done:
+ if(!ret_value && hdr)
+ if(H5B2_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, NULL, "unable to free shared v2 B-tree info")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5B2_hdr_alloc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HF_hdr_create
+ *
+ * Purpose: Create new fractal heap header
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
- * Feb 2 2005
+ * Mar 21 2006
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5B2_hdr_free(H5B2_hdr_t *hdr)
+haddr_t
+H5B2_hdr_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam)
{
- herr_t ret_value = SUCCEED;
+ H5B2_hdr_t *hdr = NULL; /* The new v2 B-tree header information */
+ haddr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_free)
+ FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_create)
- /* Sanity check */
- HDassert(hdr);
+ /*
+ * Check arguments.
+ */
+ HDassert(f);
+ HDassert(cparam);
- /* Free the B-tree node buffer */
- if(hdr->page)
- (void)H5FL_BLK_FREE(node_page, hdr->page);
+ /* Allocate v2 B-tree header */
+ if(NULL == (hdr = H5B2_hdr_alloc()))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed for B-tree header")
- /* Free the array of offsets into the native key block */
- if(hdr->nat_off)
- hdr->nat_off = H5FL_SEQ_FREE(size_t, hdr->nat_off);
+ /* Initialize shared B-tree info */
+ if(H5B2_hdr_init(f, hdr, cparam, 0) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, HADDR_UNDEF, "can't create shared B-tree info")
- /* Release the node info */
- if(hdr->node_info) {
- unsigned u; /* Local index variable */
+ /* Allocate space for the header on disk */
+ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)H5B2_HEADER_SIZE(f))))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for B-tree header")
- /* Destroy free list factories */
- for(u = 0; u < (hdr->depth + 1); u++) {
- if(hdr->node_info[u].nat_rec_fac)
- if(H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory")
- if(hdr->node_info[u].node_ptr_fac)
- if(H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory")
- } /* end for */
+ /* Cache the new B-tree node */
+ if(H5AC_set(f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, HADDR_UNDEF, "can't add B-tree header to cache")
- /* Free the array of node info structs */
- hdr->node_info = H5FL_SEQ_FREE(H5B2_node_info_t, hdr->node_info);
- } /* end if */
+ /* Set address of v2 B-tree header to return */
+ ret_value = hdr->addr;
done:
+ if(!H5F_addr_defined(ret_value) && hdr)
+ if(H5B2_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release v2 B-tree header")
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5B2_hdr_free() */
+} /* end H5B2_hdr_create() */
/*-------------------------------------------------------------------------
@@ -376,6 +420,63 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B2_hdr_free
+ *
+ * Purpose: Free B-tree header info
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Feb 2 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5B2_hdr_free(H5B2_hdr_t *hdr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5B2_hdr_free)
+
+ /* Sanity check */
+ HDassert(hdr);
+
+ /* Free the B-tree node buffer */
+ if(hdr->page)
+ (void)H5FL_BLK_FREE(node_page, hdr->page);
+
+ /* Free the array of offsets into the native key block */
+ if(hdr->nat_off)
+ hdr->nat_off = H5FL_SEQ_FREE(size_t, hdr->nat_off);
+
+ /* Release the node info */
+ if(hdr->node_info) {
+ unsigned u; /* Local index variable */
+
+ /* Destroy free list factories */
+ for(u = 0; u < (hdr->depth + 1); u++) {
+ if(hdr->node_info[u].nat_rec_fac)
+ if(H5FL_fac_term(hdr->node_info[u].nat_rec_fac) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's native record block factory")
+ if(hdr->node_info[u].node_ptr_fac)
+ if(H5FL_fac_term(hdr->node_info[u].node_ptr_fac) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "can't destroy node's node pointer block factory")
+ } /* end for */
+
+ /* Free the array of node info structs */
+ hdr->node_info = H5FL_SEQ_FREE(H5B2_node_info_t, hdr->node_info);
+ } /* end if */
+
+ /* Free B-tree header info */
+ (void)H5FL_FREE(H5B2_hdr_t, hdr);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5B2_hdr_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5B2_hdr_delete
*
* Purpose: Mark B-tree header for deletion
diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h
index b47cc32..578e39f 100644
--- a/src/H5B2pkg.h
+++ b/src/H5B2pkg.h
@@ -218,9 +218,6 @@ H5_DLLVAR const H5AC_class_t H5AC_BT2_INT[1];
/* H5B2 leaf node inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_BT2_LEAF[1];
-/* Declare a free list to manage the H5B2_hdr_t struct */
-H5FL_EXTERN(H5B2_hdr_t);
-
/* Declare a free list to manage the H5B2_internal_t struct */
H5FL_EXTERN(H5B2_internal_t);
@@ -238,13 +235,16 @@ H5_DLLVAR const H5B2_class_t H5B2_TEST[1];
/******************************/
/* Routines for managing B-tree header info */
+H5_DLL H5B2_hdr_t *H5B2_hdr_alloc(void);
+H5_DLL haddr_t H5B2_hdr_create(H5F_t *f, hid_t dxpl_id,
+ const H5B2_create_t *cparam);
+H5_DLL herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr,
+ const H5B2_create_t *cparam, unsigned depth);
H5_DLL herr_t H5B2_hdr_incr(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_decr(H5B2_hdr_t *hdr);
H5_DLL herr_t H5B2_hdr_dirty(H5B2_hdr_t *hdr);
-H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr);
-H5_DLL herr_t H5B2_hdr_init(H5F_t *f, H5B2_hdr_t *hdr,
- const H5B2_create_t *cparam, unsigned depth);
H5_DLL herr_t H5B2_hdr_free(H5B2_hdr_t *hdr);
+H5_DLL herr_t H5B2_hdr_delete(H5B2_hdr_t *hdr);
/* Routines for operating on internal nodes */
H5_DLL H5B2_internal_t *H5B2_protect_internal(H5F_t *f, hid_t dxpl_id,
diff --git a/src/H5HF.c b/src/H5HF.c
index 79032d3..7ba6e5e 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -196,10 +196,9 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
done:
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header")
- if(!ret_value) {
- if(fh)
- (void)H5HF_close(fh, dxpl_id);
- } /* end if */
+ if(!ret_value && fh)
+ if(H5HF_close(fh, dxpl_id) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_create() */
@@ -270,10 +269,9 @@ HDfprintf(stderr, "%s: hdr->rc = %u, hdr->fspace = %p\n", FUNC, hdr->rc, hdr->fs
done:
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header")
- if(!ret_value) {
- if(fh)
- (void)H5HF_close(fh, dxpl_id);
- } /* end if */
+ if(!ret_value && fh)
+ if(H5HF_close(fh, dxpl_id) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_open() */
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index b5d7cb5..b967e9d 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -434,7 +434,8 @@ done:
if(wb && H5WB_unwrap(wb) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
if(!ret_value && hdr)
- (void)H5HF_cache_hdr_dest(f, hdr);
+ if(H5HF_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_cache_hdr_load() */ /*lint !e818 Can't make udata a pointer to const */
@@ -623,16 +624,9 @@ H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap header")
} /* end if */
- /* Free the block size lookup table for the doubling table */
- H5HF_dtable_dest(&hdr->man_dtable);
-
- /* Release any I/O pipeline filter information */
- if(hdr->pline.nused)
- H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline));
-
/* Free the shared info itself */
- (void)H5FL_FREE(H5HF_hdr_t, hdr);
-
+ 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() */
diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c
index 3762af6..b386682 100644
--- a/src/H5HFhdr.c
+++ b/src/H5HFhdr.c
@@ -79,7 +79,7 @@
/*********************/
/* Declare a free list to manage the H5HF_hdr_t struct */
-H5FL_DEFINE(H5HF_hdr_t);
+H5FL_DEFINE_STATIC(H5HF_hdr_t);
/*****************************/
@@ -110,7 +110,7 @@ H5HF_hdr_t *
H5HF_hdr_alloc(H5F_t *f)
{
H5HF_hdr_t *hdr = NULL; /* Shared fractal heap header */
- H5HF_hdr_t *ret_value = NULL; /* Return value */
+ H5HF_hdr_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_hdr_alloc)
@@ -121,7 +121,7 @@ H5HF_hdr_alloc(H5F_t *f)
/* Allocate space for the shared information */
if(NULL == (hdr = H5FL_CALLOC(H5HF_hdr_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fractal heap shared header")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "allocation failed for fractal heap shared header")
/* Set the internal parameters for the heap */
hdr->f = f;
@@ -132,9 +132,9 @@ H5HF_hdr_alloc(H5F_t *f)
ret_value = hdr;
done:
- if(!ret_value)
- if(hdr)
- (void)H5HF_cache_hdr_dest(f, hdr);
+ if(!ret_value && hdr)
+ if(H5HF_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_alloc() */
@@ -472,7 +472,7 @@ HDfprintf(stderr, "%s: hdr->filter_len = %u\n", FUNC, hdr->filter_len);
*/
switch(cparam->id_len) {
case 0: /* Set the length of heap IDs to just enough to hold the offset & length of 'normal' objects in the heap */
- hdr->id_len = 1 + hdr->heap_off_size + hdr->heap_len_size;
+ hdr->id_len = (unsigned)1 + hdr->heap_off_size + hdr->heap_len_size;
break;
case 1: /* Set the length of heap IDs to just enough to hold the information needed to directly access 'huge' objects in the heap */
@@ -520,15 +520,15 @@ HDfprintf(stderr, "%s: hdr->id_len = %Zu\n", FUNC, hdr->id_len);
/* Cache the new fractal heap header */
if(H5AC_set(f, dxpl_id, H5AC_FHEAP_HDR, hdr->heap_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "can't add fractal heap header to cache")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, HADDR_UNDEF, "can't add fractal heap header to cache")
/* Set address of heap header to return */
ret_value = hdr->heap_addr;
done:
- if(!H5F_addr_defined(ret_value))
- if(hdr)
- (void)H5HF_cache_hdr_dest(NULL, hdr);
+ if(!H5F_addr_defined(ret_value) && hdr)
+ if(H5HF_hdr_free(hdr) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, HADDR_UNDEF, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_hdr_create() */
@@ -1508,6 +1508,43 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HF_hdr_free
+ *
+ * Purpose: Free shared fractal heap header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 27 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HF_hdr_free(H5HF_hdr_t *hdr)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_hdr_free)
+
+ /*
+ * Check arguments.
+ */
+ HDassert(hdr);
+
+ /* Free the block size lookup table for the doubling table */
+ H5HF_dtable_dest(&hdr->man_dtable);
+
+ /* Release any I/O pipeline filter information */
+ if(hdr->pline.nused)
+ H5O_msg_reset(H5O_PLINE_ID, &(hdr->pline));
+
+ /* Free the shared info itself */
+ hdr = H5FL_FREE(H5HF_hdr_t, hdr);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5HF_hdr_free() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HF_hdr_delete
*
* Purpose: Delete a fractal heap, starting with the header
@@ -1523,8 +1560,8 @@ done:
herr_t
H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id)
{
- unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */
- herr_t ret_value = SUCCEED;
+ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap header */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HF_hdr_delete, FAIL)
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 4f2dbc3..523b197 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -504,9 +504,6 @@ H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_NORMAL_ROW[1];
/* H5HF indirect section inherits serializable properties from H5FS_section_class_t */
H5_DLLVAR H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1];
-/* Declare a free list to manage the H5HF_hdr_t struct */
-H5FL_EXTERN(H5HF_hdr_t);
-
/* Declare a free list to manage the H5HF_indirect_t struct */
H5FL_EXTERN(H5HF_indirect_t);
@@ -564,6 +561,7 @@ H5_DLL herr_t H5HF_hdr_reverse_iter(H5HF_hdr_t *hdr, hid_t dxpl_id,
haddr_t dblock_addr);
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);
/* Indirect block routines */