summaryrefslogtreecommitdiffstats
path: root/src/H5SL.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-29 21:01:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-29 21:01:20 (GMT)
commit73df82dcdf83544c8a07b572568e9a3a3f0f9f77 (patch)
treeb56fa674812962644fcc0cadf05e073d2685c6bf /src/H5SL.c
parent51ed85b2775eba3923fb9b0c7ee887ff9284cc22 (diff)
downloadhdf5-73df82dcdf83544c8a07b572568e9a3a3f0f9f77.zip
hdf5-73df82dcdf83544c8a07b572568e9a3a3f0f9f77.tar.gz
hdf5-73df82dcdf83544c8a07b572568e9a3a3f0f9f77.tar.bz2
[svn-r9598] Purpose:
New internal feature Description: Add a "release" routine to the skip lists, which releases all the nodes in the skip list, but keeps the skip list active. Platforms tested: FreeBSD 4.10 (sleipnir) Linux 2.4 (verbena) Too minor to require h5committest
Diffstat (limited to 'src/H5SL.c')
-rw-r--r--src/H5SL.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/src/H5SL.c b/src/H5SL.c
index 9370ba7..eea4cdc 100644
--- a/src/H5SL.c
+++ b/src/H5SL.c
@@ -673,6 +673,59 @@ H5SL_item(H5SL_node_t *slist_node)
/*--------------------------------------------------------------------------
NAME
+ H5SL_release
+ PURPOSE
+ Release all nodes from a skip list
+ USAGE
+ herr_t H5SL_release(slist)
+ H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes
+
+ RETURNS
+ Returns non-negative on success, negative on failure.
+ DESCRIPTION
+ Release all the nodes in a skip list. Any objects left in the skip list
+ nodes are not deallocated.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5SL_release(H5SL_t *slist)
+{
+ H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */
+ size_t u; /* Local index variable */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_release);
+
+ /* Check args */
+ assert(slist);
+
+ /* Check internal consistency */
+ /* (Pre-condition) */
+
+ /* Free skip list nodes */
+ node=slist->header->forward[0];
+ while(node!=NULL) {
+ next_node=node->forward[0];
+ H5MM_xfree(node);
+ node=next_node;
+ } /* end while */
+
+ /* Reset the header pointers */
+ for(u=0; u<slist->max_level; u++)
+ slist->header->forward[u]=NULL;
+
+ /* Reset the dynamic internal fields */
+ slist->curr_level=-1;
+ slist->nobjs=0;
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5SL_release() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
H5SL_close
PURPOSE
Close a skip list, deallocating it.
@@ -693,8 +746,6 @@ H5SL_item(H5SL_node_t *slist_node)
herr_t
H5SL_close(H5SL_t *slist)
{
- H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */
-
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_close);
/* Check args */
@@ -704,12 +755,10 @@ H5SL_close(H5SL_t *slist)
/* (Pre-condition) */
/* Free skip list nodes */
- node=slist->header;
- while(node!=NULL) {
- next_node=node->forward[0];
- H5MM_xfree(node);
- node=next_node;
- } /* end while */
+ H5SL_release(slist); /* always succeeds */
+
+ /* Release header node */
+ H5MM_xfree(slist->header);
/* Free skip list object */
H5FL_FREE(H5SL_t,slist);