summaryrefslogtreecommitdiffstats
path: root/src/H5HLint.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-12-14 05:34:41 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-12-14 05:34:41 (GMT)
commit3cdcdbc03e00648d2b37c68dec06e8f93e97d738 (patch)
treee667ec19d8d9318183a7c243ae8c5a3509b2b971 /src/H5HLint.c
parent91f01bd7025b796ada843cf786e3a660a7886106 (diff)
downloadhdf5-3cdcdbc03e00648d2b37c68dec06e8f93e97d738.zip
hdf5-3cdcdbc03e00648d2b37c68dec06e8f93e97d738.tar.gz
hdf5-3cdcdbc03e00648d2b37c68dec06e8f93e97d738.tar.bz2
[svn-r28616] Normalization of H5HL package with revise_chunks.
NOTE: Flush dependency code was not moved. Tested on: Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 w/ CMake 3.3.2 serial only (Autotools and CMake since new files were added) (these changes have been in revise_chunks for a long time)
Diffstat (limited to 'src/H5HLint.c')
-rw-r--r--src/H5HLint.c317
1 files changed, 61 insertions, 256 deletions
diff --git a/src/H5HLint.c b/src/H5HLint.c
index bbf579d..5b547cf 100644
--- a/src/H5HLint.c
+++ b/src/H5HLint.c
@@ -15,11 +15,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5HLint.c
- * Oct 12 2008
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5HLint.c
+ * Oct 12 2008
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Local heap internal routines.
+ * Purpose: Local heap internal routines.
*
*-------------------------------------------------------------------------
*/
@@ -34,9 +34,10 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5HLpkg.h" /* Local Heaps */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5HLpkg.h" /* Local Heaps */
/****************/
@@ -76,35 +77,26 @@
/* Declare a free list to manage the H5HL_t struct */
H5FL_DEFINE_STATIC(H5HL_t);
-/* Declare a free list to manage the H5HL_dblk_t struct */
-H5FL_DEFINE_STATIC(H5HL_dblk_t);
-
-/* Declare a free list to manage the H5HL_prfx_t struct */
-H5FL_DEFINE_STATIC(H5HL_prfx_t);
-
/*-------------------------------------------------------------------------
- * Function: H5HL_new
+ * Function: H5HL__new
*
- * Purpose: Create a new local heap object
+ * Purpose: Create a new local heap object
*
- * Return: Success: non-NULL pointer to new local heap
- * Failure: NULL
+ * Return: Success: non-NULL pointer to new local heap
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jan 5 2010
+ * Programmer: Quincey Koziol
+ * Jan 5 2010
*
*-------------------------------------------------------------------------
*/
-H5HL_t *
-H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
-{
- H5HL_t *heap = NULL; /* New local heap */
- H5HL_t *ret_value = NULL; /* Return value */
+BEGIN_FUNC(PKG, ERR,
+H5HL_t *, NULL, NULL,
+H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size))
- FUNC_ENTER_NOAPI(NULL)
+ H5HL_t *heap = NULL; /* New local heap */
/* check arguments */
HDassert(sizeof_size > 0);
@@ -113,7 +105,7 @@ H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
/* Allocate new local heap structure */
if(NULL == (heap = H5FL_CALLOC(H5HL_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
+ H5E_THROW(H5E_CANTALLOC, "memory allocation failed");
/* Initialize non-zero fields */
heap->sizeof_size = sizeof_size;
@@ -123,29 +115,29 @@ H5HL_new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)
/* Set the return value */
ret_value = heap;
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_new() */
+CATCH
+ if(!ret_value && heap != NULL)
+ if (NULL == (heap = H5FL_FREE(H5HL_t, heap)))
+ H5E_THROW(H5E_CANTFREE, "can't free heap memory");
+
+END_FUNC(PKG) /* end H5HL__new() */
/*-------------------------------------------------------------------------
* Function: H5HL__inc_rc
*
- * Purpose: Increment ref. count on heap
+ * Purpose: Increment ref. count on heap
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED (Can't fail)
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL__inc_rc(H5HL_t *heap)
-{
- FUNC_ENTER_STATIC_NOERR
+BEGIN_FUNC(PKG, NOERR,
+herr_t, SUCCEED, -,
+H5HL__inc_rc(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -153,28 +145,24 @@ H5HL__inc_rc(H5HL_t *heap)
/* Increment heap's ref. count */
heap->rc++;
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL__inc_rc() */
+END_FUNC(PKG) /* end H5HL__inc_rc() */
/*-------------------------------------------------------------------------
* Function: H5HL__dec_rc
*
- * Purpose: Decrement ref. count on heap
+ * Purpose: Decrement ref. count on heap
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
+ * Programmer: Quincey Koziol
+ * Oct 12 2008
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5HL__dec_rc(H5HL_t *heap)
-{
- FUNC_ENTER_STATIC_NOERR
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dec_rc(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -182,31 +170,29 @@ H5HL__dec_rc(H5HL_t *heap)
/* Decrement heap's ref. count */
heap->rc--;
+CATCH
/* Check if we should destroy the heap */
- if(heap->rc == 0)
- H5HL_dest(heap);
+ if(heap->rc == 0 && FAIL == H5HL__dest(heap))
+ H5E_THROW(H5E_CANTFREE, "unable to destroy local heap");
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL__dec_rc() */
+END_FUNC(PKG) /* end H5HL__dec_rc() */
/*-------------------------------------------------------------------------
- * Function: H5HL_dest
+ * Function: H5HL__dest
*
- * Purpose: Destroys a heap in memory.
+ * Purpose: Destroys a heap in memory.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jan 15 2003
+ * Programmer: Quincey Koziol
+ * Jan 15 2003
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5HL_dest(H5HL_t *heap)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+BEGIN_FUNC(PKG, ERR,
+herr_t, SUCCEED, FAIL,
+H5HL__dest(H5HL_t *heap))
/* check arguments */
HDassert(heap);
@@ -217,201 +203,20 @@ H5HL_dest(H5HL_t *heap)
HDassert(heap->prfx == NULL);
HDassert(heap->dblk == NULL);
+CATCH
if(heap->dblk_image)
- heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image);
+ if(NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap data block image");
while(heap->freelist) {
H5HL_free_t *fl;
fl = heap->freelist;
heap->freelist = fl->next;
- fl = H5FL_FREE(H5HL_free_t, fl);
+ if(NULL != (fl = H5FL_FREE(H5HL_free_t, fl)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap free list");
} /* end while */
- heap = H5FL_FREE(H5HL_t, heap);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5HL_dest() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_prfx_new
- *
- * Purpose: Create a new local heap prefix object
- *
- * Return: Success: non-NULL pointer to new local heap prefix
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-H5HL_prfx_t *
-H5HL_prfx_new(H5HL_t *heap)
-{
- H5HL_prfx_t *prfx = NULL; /* New local heap prefix */
- H5HL_prfx_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* check arguments */
- HDassert(heap);
-
- /* Allocate new local heap prefix */
- if(NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
-
- /* Increment ref. count on heap data structure */
- if(H5HL__inc_rc(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count")
-
- /* Link the heap & the prefix */
- prfx->heap = heap;
- heap->prfx = prfx;
-
- /* Set the return value */
- ret_value = prfx;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_prfx_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_prfx_dest
- *
- * Purpose: Destroy a local heap prefix object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_prfx_dest(H5HL_prfx_t *prfx)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check arguments */
- HDassert(prfx);
-
- /* Check if prefix was initialized */
- if(prfx->heap) {
- /* Unlink prefix from heap */
- prfx->heap->prfx = NULL;
-
- /* Decrement ref. count on heap data structure */
- if(H5HL__dec_rc(prfx->heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count")
-
- /* Unlink heap from prefix */
- prfx->heap = NULL;
- } /* end if */
-
- /* Free local heap prefix */
- prfx = H5FL_FREE(H5HL_prfx_t, prfx);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_prfx_dest() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_dblk_new
- *
- * Purpose: Create a new local heap data block object
- *
- * Return: Success: non-NULL pointer to new local heap data block
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-H5HL_dblk_t *
-H5HL_dblk_new(H5HL_t *heap)
-{
- H5HL_dblk_t *dblk = NULL; /* New local heap data block */
- H5HL_dblk_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* check arguments */
- HDassert(heap);
-
- /* Allocate new local heap data block */
- if(NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed")
-
- /* Increment ref. count on heap data structure */
- if(H5HL__inc_rc(heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count")
-
- /* Link the heap & the data block */
- dblk->heap = heap;
- heap->dblk = dblk;
-
- /* Set the return value */
- ret_value = dblk;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dblk_new() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_dblk_dest
- *
- * Purpose: Destroy a local heap data block object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 12 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_dblk_dest(H5HL_dblk_t *dblk)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check arguments */
- HDassert(dblk);
-
- /* Check if data block was initialized */
- if(dblk->heap) {
- /* Unlink data block from heap */
- dblk->heap->dblk = NULL;
-
- /* Unpin the local heap prefix */
- if(H5AC_unpin_entry(dblk->heap->prfx) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "can't unpin local heap prefix")
-
- /* Decrement ref. count on heap data structure */
- if(H5HL__dec_rc(dblk->heap) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count")
-
- /* Unlink heap from data block */
- dblk->heap = NULL;
- } /* end if */
-
- /* Free local heap data block */
- dblk = H5FL_FREE(H5HL_dblk_t, dblk);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HL_dblk_dest() */
+
+ if(NULL != (heap = H5FL_FREE(H5HL_t, heap)))
+ H5E_THROW(H5E_CANTFREE, "unable to free local heap");
+END_FUNC(PKG) /* end H5HL__dest() */