summaryrefslogtreecommitdiffstats
path: root/src/H5FL.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-02-03 19:59:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-02-03 19:59:05 (GMT)
commit0b332ace5e6a94c1238b99268675a9ba840215c0 (patch)
tree373c7c8d4533ea7273d4bfd9c4bf72a559399b5a /src/H5FL.c
parent3bf1bfa4ec9988e038944b59fcaa8acc2d79f734 (diff)
downloadhdf5-0b332ace5e6a94c1238b99268675a9ba840215c0.zip
hdf5-0b332ace5e6a94c1238b99268675a9ba840215c0.tar.gz
hdf5-0b332ace5e6a94c1238b99268675a9ba840215c0.tar.bz2
[svn-r9928] Purpose:
New feature Description: Add basic code for new B-tree implementation. They don't do much yet, aren't hooked up to anything yet and the format may change, but I'd like to start getting them into the daily tests. Platforms tested: FreeBSD 4.11 (sleipnir) w/parallel Too minor to require h5committest
Diffstat (limited to 'src/H5FL.c')
-rw-r--r--src/H5FL.c188
1 files changed, 188 insertions, 0 deletions
diff --git a/src/H5FL.c b/src/H5FL.c
index 3041b57..be5ff8d 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -105,6 +105,9 @@ static herr_t H5FL_arr_gc_list(H5FL_arr_head_t *head);
static herr_t H5FL_blk_gc(void);
static herr_t H5FL_blk_gc_list(H5FL_blk_head_t *head);
+/* Declare a free list to manage the H5FL_fac_head_t struct */
+H5FL_DEFINE(H5FL_fac_head_t);
+
/* Declare a free list to manage the H5FL_blk_node_t struct */
H5FL_DEFINE(H5FL_blk_node_t);
@@ -1775,6 +1778,191 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5FL_fac_init
+ *
+ * Purpose: Initialize a block factory
+ *
+ * Return: Success: Pointer to factory object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 2, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5FL_fac_head_t *
+H5FL_fac_init(size_t size)
+{
+ H5FL_fac_head_t *factory; /* Pointer to new block factory */
+ H5FL_fac_head_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FL_fac_init, NULL)
+
+ /* Sanity check */
+ HDassert(size>0);
+
+ /* Allocate room for the new factory */
+ if(NULL==(factory=H5FL_MALLOC(H5FL_fac_head_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for factory object")
+
+ /* Initialize block header information */
+ HDmemset(&(factory->queue),0,sizeof(H5FL_blk_head_t));
+
+ /* Set size of blocks for factory */
+ factory->size=size;
+
+ /* Set return value */
+ ret_value=factory;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FL_fac_init() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FL_fac_free
+ *
+ * Purpose: Release a block back to a factory & put on free list
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 2, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5FL_fac_free(H5FL_fac_head_t *head, void *obj)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_fac_free)
+
+ /* Double check parameters */
+ assert(head);
+ assert(obj);
+
+ /* Make certain that the free list is initialized */
+ assert(head->queue.init);
+
+ /* Use block routine */
+ H5FL_blk_free(&(head->queue),obj);
+
+ FUNC_LEAVE_NOAPI(NULL)
+} /* end H5FL_fac_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FL_fac_malloc
+ *
+ * Purpose: Allocate a block from a factory
+ *
+ * Return: Success: Pointer to a valid sequence object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 2, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5FL_fac_malloc(H5FL_fac_head_t *head)
+{
+ void *ret_value; /* Pointer to object to return */
+
+ FUNC_ENTER_NOAPI(H5FL_fac_malloc, NULL)
+
+ /* Double check parameters */
+ assert(head);
+
+ /* Use block routine */
+ ret_value=H5FL_blk_malloc(&(head->queue),head->size);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FL_fac_malloc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FL_fac_calloc
+ *
+ * Purpose: Allocate a block from a factory and clear it to zeros
+ *
+ * Return: Success: Pointer to a valid array object
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 2, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5FL_fac_calloc(H5FL_fac_head_t *head)
+{
+ void *ret_value; /* Pointer to object to return */
+
+ FUNC_ENTER_NOAPI(H5FL_fac_calloc, NULL)
+
+ /* Double check parameters */
+ assert(head);
+
+ /* Use block routine */
+ ret_value=H5FL_blk_calloc(&(head->queue),head->size);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FL_fac_calloc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FL_fac_term
+ *
+ * Purpose: Terminate a block factory
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, February 2, 2005
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FL_fac_term(H5FL_fac_head_t *factory)
+{
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5FL_fac_term)
+
+ /* Sanity check */
+ HDassert(factory);
+
+ /* Garbage collect all the blocks in the factory's free list */
+ if(H5FL_blk_gc_list(&(factory->queue))<0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGC, FAIL, "garbage collection of factory failed")
+
+ /* Verify that all the blocks have been freed */
+ if(factory->queue.allocated>0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "factory still has objects allocated")
+
+ /* Free factory info */
+ H5FL_FREE(H5FL_fac_head_t,factory);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FL_fac_term() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5FL_garbage_coll
*
* Purpose: Garbage collect on all the free lists