Serj Kalichev 4 months ago
parent
commit
d0411fa33c

File diff suppressed because it is too large
+ 2494 - 0
Doxyfile


+ 2 - 2
Makefile.am

@@ -26,7 +26,7 @@ nobase_include_HEADERS =
 EXTRA_DIST = \
 	bin/module.am \
 	clish/module.am \
-	lub/module.am \
+	lub/Makefile.am \
 	tinyrl/module.am \
 	konf/module.am \
 	plugins/module.am \
@@ -41,7 +41,7 @@ EXTRA_DIST = \
 	CHANGES \
 	ISSUES
 
-include $(top_srcdir)/lub/module.am
+include $(top_srcdir)/lub/Makefile.am
 include $(top_srcdir)/tinyrl/module.am
 include $(top_srcdir)/konf/module.am
 include $(top_srcdir)/clish/module.am

+ 0 - 0
docs/Makefile.am


+ 1 - 1
lub/module.am

@@ -37,7 +37,7 @@ include $(top_srcdir)/lub/bintree/module.am
 include $(top_srcdir)/lub/list/module.am
 include $(top_srcdir)/lub/ctype/module.am
 include $(top_srcdir)/lub/dump/module.am
-include $(top_srcdir)/lub/string/module.am
+include $(top_srcdir)/lub/str/Makefile.am
 include $(top_srcdir)/lub/system/module.am
 include $(top_srcdir)/lub/db/module.am
 include $(top_srcdir)/lub/ini/module.am

+ 0 - 463
lub/bintree.h

@@ -1,463 +0,0 @@
-/**
-\ingroup lub
-\defgroup lub_bintree bintree
- @{
-
-\brief This interface provides a facility which enables a client to 
- order and access a set of arbitary data in a binary "tree"
- 
- Each "tree" is defined by a number of "clientnodes" which are
- ordered according to a client defined "key".
-
- A "clientkey" is a client specific entity which can be compared
- with a "clientnode" to determine which is the "greatest". In order
- to do this the client needs provide a comparison function for
- comparing a "clientnode" with a "clientkey", and a function to
- convert a "clientnode" into a "clientkey".
-
- The client is responsible for providing each "clientnode" in a
- tree. This will typically contain some client specific data, but
- will also need to contain a bintree "node" which is used to
- structurally relate each node to one another in the tree. A
- specific "node" may only belong to one tree at a time, but an
- individual "clientnode" may contain multiple of these if necessary.
-
-\par Implementation
-The implementation of this interface uses a top-down splaying algorithm.
-
-\par 
-"Splay trees", or "self-adjusting search trees" are a simple and
-efficient data structure for storing an ordered set.  The data
-structure consists of a binary tree, without parent pointers, and
-no additional fields.  It allows searching, insertion, deletion,
-deletemin, deletemax, splitting, joining, and many other
-operations, all with amortized logarithmic performance.  Since the
-trees adapt to the sequence of requests, their performance on real
-access patterns is typically even better.  Splay trees are
-described in a number of texts and papers [1,2,3,4,5].
-
-\par
-The code here is adapted from simple top-down splay, at the bottom
-of page 669 of [3].  It can be obtained via anonymous ftp from
-spade.pc.cs.cmu.edu in directory /usr/sleator/public.
-
-\par
-The chief modification here is that the splay operation works even
-if the item being splayed is not in the tree, and even if the tree
-root of the tree is NULL.  So the line:
-
-\par
-                           t = splay(i, t);
-
-\par
-causes it to search for item with key i in the tree rooted at t.
-If it's there, it is splayed to the root.  If it isn't there,
-then the node put at the root is the last one before NULL that
-would have been reached in a normal binary search for i.  (It's a
-neighbor of i in the tree.)  This allows many other operations to
-be easily implemented.
-
-\par
-[1] "Fundamentals of data structures in C", Horowitz, Sahni,
-     and Anderson-Freed, Computer Science Press, pp 542-547.
-
-\par
-[2] "Data Structures and Their Algorithms", Lewis and Denenberg,
-     Harper Collins, 1991, pp 243-251.
-
-\par
-[3] "Self-adjusting Binary Search Trees" Sleator and Tarjan,
-    JACM Volume 32, No 3, July 1985, pp 652-686.
-
-\par
-[4] "Data Structure and Algorithm Analysis", Mark Weiss,
-    Benjamin Cummins, 1992, pp 119-130.
-
-\par
-[5] "Data Structures, Algorithms, and Performance", Derick Wood,
-     Addison-Wesley, 1993, pp 367-375.
-
-\par
-The splay function is based on one written by Daniel Sleator, which is released
-in the public domain.
- 
-\author  Graeme McKerrell
-\date    Created On      : Fri Jan 23 12:50:18 2004
-\version TESTED
- */
-/*---------------------------------------------------------------
- HISTORY
- 7-Dec-2004		Graeme McKerrell	
-   Updated to use the "lub" prefix
-27-Feb-2004		Graeme McKerrell	
-   updated to simplify node initialisation
-9-Feb-2004		Graeme McKerrell	
-   updated to make the comparision function compare a "clientnode" and
-   "key"
-   Updated getkey() function to fill out a provides "key" from a "clientnode"
-23-Jan-2004		Graeme McKerrell	
-   Initial version
---------------------------------------------------------------
-Copyright (C) 2004 3Com Corporation. All Rights Reserved.
-**************************************************************** */
-#ifndef _lub_bintree_h
-#define _lub_bintree_h
-#include <stddef.h>
-
-/****************************************************************
- * TYPE DEFINITIONS
- **************************************************************** */
-/**
- * This type represents a bintree "node".
- * Typically the client will have a "clientnode" structure which
- * contains it's data. A bintree "node" is made one of the data
- * elements of that structure. When the tree is initialised the
- * client provides the offset into the structure of the
- * "node" which is to be used for that tree.
- */
-typedef struct lub_bintree_node_s lub_bintree_node_t;
-/** 
- * CLIENTS MUSTN'T TOUCH THE CONTENTS OF THIS STRUCTURE
- */
-struct lub_bintree_node_s {
-	/** internal */ lub_bintree_node_t *left;
-	/** internal */ lub_bintree_node_t *right;
-};
-
-/**
- * This type defines a callback function which will compare two "keys"
- * with each other
- *
- * \param clientnode 	the client node to compare
- * \param clientkey 	the key to compare with a node
- *
- * \return
- *     <0 if clientnode  < clientkey;
- *      0 if clientnode == clientkey;
- *     >0 if clientnode  > clientkey
- */
-typedef int
-lub_bintree_compare_fn(const void *clientnode, const void *clientkey);
-/**
- * This is used to size the key storage area for an opaque key.
- * If any client requires a greater storage size then this will need to
- * be increased.
- */
-#define lub_bintree_MAX_KEY_STORAGE (200)
-/**
- * This is used to declare an opaque key structure
- * Typically a client would declare their own non-opaque structure
- * which they would fill out appropriately
- */
-typedef struct lub_bintree_key_s lub_bintree_key_t;
-/** 
- * CLIENTS MUSTN'T TOUCH THE CONTENTS OF THIS STRUCTURE
- */
-struct lub_bintree_key_s {
-    /** internal */ char storage[lub_bintree_MAX_KEY_STORAGE];
-    /** internal */ int magic;
-};
-
-/**
- * This type defines a callback function which will convert a client's "node"
- * into a search "key"
- * 
- * \param clientnode 	the node from which to derive a key
- * \param key        	a reference to the key to fill out
- * 
- * \return
- * A "key" which corresponds the "node" in this view
- */
-typedef void
-lub_bintree_getkey_fn(const void *clientnode, lub_bintree_key_t * key);
-
-/**
- * This type represents an binary tree instance
- */
-typedef struct lub_bintree_s lub_bintree_t;
-/** 
- * CLIENTS MUSTN'T TOUCH THE CONTENTS OF THIS STRUCTURE
- */
-struct lub_bintree_s {
-	/** internal */ lub_bintree_node_t *root;
-	/** internal */ size_t node_offset;
-	/** internal */ lub_bintree_compare_fn *compareFn;
-	/** internal */ lub_bintree_getkey_fn *getkeyFn;
-};
-
-/**
- * This is used to perform iterations of a tree
- */
-typedef struct lub_bintree_iterator_s lub_bintree_iterator_t;
-/** 
- * CLIENTS MUSTN'T TOUCH THE CONTENTS OF THIS STRUCTURE
- */
-struct lub_bintree_iterator_s {
-	/** internal */ lub_bintree_t *tree;
-    /** internal */ lub_bintree_key_t key;
-};
-
-/****************************************************************
- * BINTREE OPERATIONS
- **************************************************************** */
-/**
- * This operation initialises an instance of a binary tree.
- *
- * \pre none
- *
- * \post The tree is ready to have client nodes inserted.
- */
-extern void lub_bintree_init(
-		/** 
-		* the "tree" instance to initialise 
-		*/
-				    lub_bintree_t * tree,
-		/** 
-		* the offset of the bintree "node" structure within the
-		* "clientnode" structure. This is typically passed 
-		* using the offsetof() macro.
-		*/
-				    size_t node_offset,
-		/**
-		* a comparison function for comparing a "clientnode"
-		* with a "clientkey"
-		*/
-				    lub_bintree_compare_fn compareFn,
-		/**
-		* a function which will fill out a "key" from a clientnode
-		*/
-				    lub_bintree_getkey_fn getkeyFn);
-
-/**
- * This operation is called to initialise a "clientnode" ready for
- * insertion into a tree. This is only required once after the memory
- * for a node has been allocated.
- *
- * \pre none
- *
- * \post The node is ready to be inserted into a tree.
- */
-extern void lub_bintree_node_init(
-			/** 
-			 * the bintree node to initialise
-			  */
-					 lub_bintree_node_t * node);
-
-/*****************************************
- * NODE MANIPULATION OPERATIONS
- ***************************************** */
-/**
- * This operation adds a client node to the specified tree.
- *
- * \pre The tree must be initialised
- * \pre The clientnode must be initialised
- * 
- * \return
- * 0 if the "clientnode" is added correctly to the tree.
- * If another "clientnode" already exists in the tree with the same key, then
- * -1 is returned, and the tree remains unchanged.
- *
- * \post If the bintree "node" is already part of a tree, then an
- * assert will fire.
- */
-extern int lub_bintree_insert(
-			/**
-			 * the "tree" instance to invoke this operation upon
-			 */
-				     lub_bintree_t * tree,
-			/** 
-			 * a pointer to a client node. NB the tree can find the
-			 * necessary lub_BintreeNodeT from it's stored offset.
-			 */
-				     void *clientnode);
-
-/**
- * This operation removes a "clientnode" from the specified "tree"
- *
- * \pre The tree must be initialised
- * \pre The clientnode must be initialised
-*
- * \post The "clientnode" will no longer be part of the specified tree, and will be
- * made available for re-insertion
- * \post If the clientnode is not present in the specified tree, then an
- *  assert will fire.
- */
-extern void lub_bintree_remove(
-			/** 
-			* the "tree" instance to invoke this operation upon
-			*/
-				      lub_bintree_t * tree,
-			/**
-			* the node to remove
-			*/
-				      void *clientnode);
-
-/*****************************************
- * NODE RETRIEVAL OPERATIONS
- ***************************************** */
-/**
- * This operation returns the first "clientnode" present in the specified "tree"
- *
- * \pre The tree must be initialised
- *
- * \return
- * "clientnode" instance or NULL if no nodes are present in this tree.
- */
-extern void *lub_bintree_findfirst(
-		/** 
-		 * the "tree" instance to invoke this operation upon
-		 */
-					  lub_bintree_t * tree);
-
-/**
- * This operation returns the last "clientnode" present in the specified "tree"
- *
- * \pre The tree must be initialised
- *
- * \return
- * "clientnode" instance or NULL if no nodes are present in this tree.
- */
-extern void *lub_bintree_findlast(
-		/** 
-		* the "tree" instance to invoke this operation upon
-		*/
-					 lub_bintree_t * tree);
-
-/**
- * This operation searches the specified "tree" for a "clientnode" which matches the
- * specified "key"
- *
- * \pre The tree must be initialised
- *
- * \return
- * "clientnode" instance or NULL if no node is found.
- */
-extern void *lub_bintree_find(
-		/** 
-		 * the "tree" instance to invoke this operation upon
-		 */
-				     lub_bintree_t * tree,
-		/** 
-		  * the "key" to search with
-		  */
-				     const void *key);
-
-/**
- * This operation searches the specified "tree" for a "clientnode" which is
- * the one which logically follows the specified "key"
- *
- * A "clientnode" with the specified "key" doesn't need to be in the tree.
- *
- * \pre The tree must be initialised
- *
- * \return
- * "clientnode" instance or NULL if no node is found.
- */
-extern void *lub_bintree_findnext(
-		/** 
-		 * the "tree" instance to invoke this operation upon
-		 */
-					 lub_bintree_t * tree,
-		/** 
-		  * the "key" to search with
-		  */
-					 const void *key);
-
-/**
- * This operation searches the specified "tree" for a "clientnode" which is
- * the one which logically preceeds the specified "key"
- *
- * A "clientnode" with the specified "key" doesn't need to be in the tree.
- *
- * \pre The tree must be initialised
- *
- * \return
- * "clientnode" instance or NULL if no node is found.
- */
-extern void *lub_bintree_findprevious(
-		/** 
-		 * the "tree" instance to invoke this operation upon
-		 */
-					     lub_bintree_t * tree,
-		/** 
-		  * the "key" to search with
-		  */
-					     const void *key);
-
-/*****************************************
- * ITERATION OPERATIONS
- ***************************************** */
-/**
- * This operation initialises an iterator. This can then be
- * subsequently used for iterating through a tree. This will work
- * even if the "clientnode" which defined the current iterator has been
- * removed before the next iterator operation.
- *
- * \pre The tree must be initialised
- * \pre The clientnode must be initialised and valid at the time of this call
- *
- * \post The interator instance will be updated to reference the position in the tree for the clientnode.
- */
-extern void lub_bintree_iterator_init(
-			/** 
-			* the iterator instance to initialise
-			*/
-					     lub_bintree_iterator_t * iter,
-			/** 
-			* the tree to associate with this iterator
-			*/
-					     lub_bintree_t * tree,
-			/** 
-			 * the starting point for the iteration
-			 */
-					     const void *clientnode);
-
-/**
- * This operation returns the next "clientnode" in an iteration.
- *
- * \pre The interator instance must have been initialised
- *
- * \return
- * "clientnode" instance or NULL if the iteration has reached the end of the
- * tree.
- *
- * \post The interator instance will be updated to reference the position in the tree for the returned value.
- */
-extern void *lub_bintree_iterator_next(
-		/** 
-		 * the iterator instance to invoke this operation upon.
-		 */
-					      lub_bintree_iterator_t * iter);
-
-/**
- * This operation returns the previous "clientnode" in an iteration.
- *
- * \pre The interator instance must have been initialised
- *
- * \return
- * "clientnode" instance or NULL if the iteration has reached the beginning
- * of the tree.
- *
- * \post The interator instance will be updated to reference the position in the tree for the returned value.
- */
-extern void *lub_bintree_iterator_previous(
-		/** 
-		 * the iterator instance to invoke this operation upon.
-		 */
-						  lub_bintree_iterator_t *
-						  iter);
-/**
- * This operation dumps the node list of the specified tree to stdout
- *
- * \pre The tree must be initialised
- *
- * \post The structure of the tree will be unaltered.
- */
-extern void lub_bintree_dump(
-	/** 
-	 * the "tree" instance to invoke this operation upon
-	 */
-				    lub_bintree_t * tree);
-
-#endif				/* _lub_bintree_h */
-/** @} */

+ 0 - 34
lub/bintree/bintree_dump.c

@@ -1,34 +0,0 @@
-#ifdef DEBUG
-
-/*
- * bintree_dump.c
- */
-
-#include <stdio.h>
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void _lub_bintree_dump(lub_bintree_t * this, lub_bintree_node_t * node)
-{
-	if (node->left) {
-		_lub_bintree_dump(this, node->left);
-	}
-	printf(" %s%p",
-	       (this->root == node) ? "(R)" : "",
-	       lub_bintree_getclientnode(this, node));
-	if (node->right) {
-		_lub_bintree_dump(this, node->right);
-	}
-}
-
-/*--------------------------------------------------------- */
-void lub_bintree_dump(lub_bintree_t * this)
-{
-	if (this->root) {
-		_lub_bintree_dump(this, this->root);
-	}
-}
-
-/*--------------------------------------------------------- */
-
-#endif /* DEBUG */

+ 0 - 47
lub/bintree/bintree_find.c

@@ -1,47 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_find.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation searches the specified "tree" for a "clientnode"
- * which matches the specified "key"
- *
- * tree - the "tree" instance to invoke this operation upon
- * key  - the "key" to search with
- *
- * RETURNS
- * "clientnode" instance or NULL if no node is found.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:29:54 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 27-Feb-2004		Graeme McKerrell	
- *    Fixed to account for empty tree
- * 9-Feb-2004		Graeme McKerrell	
- *    update to use new node,key comparison ordering
- * 28-Jan-2004		Graeme McKerrell	
- *   Initial version 
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void *lub_bintree_find(lub_bintree_t * this, const void *clientkey)
-{
-	this->root = lub_bintree_splay(this, this->root, clientkey);
-
-	if (NULL != this->root) {
-		if (lub_bintree_compare(this, this->root, clientkey) == 0)
-			return lub_bintree_getclientnode(this, this->root);
-	}
-	return NULL;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 79
lub/bintree/bintree_findfirst.c

@@ -1,79 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_findfirst.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation returns the first "clientnode" present in the specified "tree"
- *
- * tree - the "tree" instance to invoke this operation upon
- *
- * RETURNS
- * "clientnode" instance or NULL if no nodes are present in this view.
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:15:00 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 2-Mar-2004		Graeme McKerrell	
- *    fixed comparison logic
- * 9-Feb-2004		Graeme McKerrell	
- *    update to use new getkey prototype, removed the now spurious
- *    nullgetkey() function
- * 28-Jan-2004		Graeme McKerrell	
- *   Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/* forward declare these functions */
-static lub_bintree_compare_fn compareleft;
-
-/*--------------------------------------------------------- */
-void *lub_bintree_findfirst(lub_bintree_t * this)
-{
-	lub_bintree_compare_fn *client_compare = this->compareFn;
-
-	/*
-	 * put dummy functions in place
-	 * This will make the search faster and direct it to the left most
-	 * node
-	 */
-	this->compareFn = compareleft;
-
-	/*
-	 * the key doesn't matter here cos we've cobbled the compare function
-	 */
-	this->root = lub_bintree_splay(this, this->root, NULL);
-
-	/* restore the client functions */
-	this->compareFn = client_compare;
-
-	if (NULL == this->root)
-		return NULL;
-	else
-		return lub_bintree_getclientnode(this, this->root);
-}
-
-/*--------------------------------------------------------- */
-/*
- * This comparison operation always returns 1 hence will force a
- * search to the left most node.
- *
- * clientnode - node to compare (not used)
- * clientkey  - key to compare (not used)
- */
-static int compareleft(const void *clientnode, const void *clientkey)
-{
-	clientnode = clientnode;
-	clientkey = clientkey;
-	return 1;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 80
lub/bintree/bintree_findlast.c

@@ -1,80 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_findlast.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation returns the last "clientnode" present in the
- * specified "tree"
- *
- * tree - the "tree" instance to invoke this operation upon
- *
- * RETURNS
- * "clientnode" instance or NULL if no nodes are present in this view.
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:17:17 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 2-Mar-2004		Graeme McKerrell	
- *    fixed comparison logic
- * 9-Feb-2004		Graeme McKerrell	
- *    update to use new getkey prototype, removed the now spurious
- *    nullgetkey() function
- * 28-Jan-2004		Graeme McKerrell	
- *   Initial version 
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/* forward declare these functions */
-static lub_bintree_compare_fn compareright;
-
-/*--------------------------------------------------------- */
-void *lub_bintree_findlast(lub_bintree_t * this)
-{
-	lub_bintree_compare_fn *client_compare = this->compareFn;
-
-	/*
-	 * put dummy functions in place
-	 * This will make the search faster and direct it to the right most
-	 * node
-	 */
-	this->compareFn = compareright;
-
-	/*
-	 * the key doesn't matter here cos we've cobbled the compare function
-	 */
-	this->root = lub_bintree_splay(this, this->root, NULL);
-
-	/* restore the client functions */
-	this->compareFn = client_compare;
-
-	if (NULL == this->root)
-		return NULL;
-	else
-		return lub_bintree_getclientnode(this, this->root);
-}
-
-/*--------------------------------------------------------- */
-/*
- * This comparison operation always returns -1 hence will force a
- * search to the left most node.
- *
- * key1 - first node to compare (not used)
- * key2 - second node to compare (not used)
- */
-static int compareright(const void *clientnode, const void *clientkey)
-{
-	clientnode = clientnode;
-	clientkey = clientkey;
-	return -1;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 67
lub/bintree/bintree_findnext.c

@@ -1,67 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_findnext.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation searches the specified "tree" for a "clientnode" which is
- * the one which logically follows the specified "key"
- *
- * A "clientnode" with the specified "key" doesn't need to be in the tree.
- *
- * tree - the "tree" instance to invoke this operation upon
- * key  - the "key" to search with
- *
- * RETURNS
- * "clientnode" instance or NULL if no node is found.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:32:28 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 27-Feb-2004		Graeme McKerrell	
- *    Fixed to account for empty tree
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new node,key comparison ordering
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void *lub_bintree_findnext(lub_bintree_t * this, const void *clientkey)
-{
-	lub_bintree_node_t *t = this->root;
-	int comp;
-
-	/*
-	 * have a look for a direct match
-	 */
-	t = this->root = lub_bintree_splay(this, t, clientkey);
-
-	if (NULL != t) {
-		/* now look at what we have got */
-		comp = lub_bintree_compare(this, t, clientkey);
-		if (comp <= 0) {
-			/*
-			 * time to fiddle with the right hand side of the tree
-			 * we need the closest node from the right hand side
-			 */
-			t = t->right =
-			    lub_bintree_splay(this, t->right, clientkey);
-		}
-	}
-	if (NULL == t) {
-		return NULL;
-	} else {
-		return lub_bintree_getclientnode(this, t);
-	}
-}
-
-/*--------------------------------------------------------- */

+ 0 - 67
lub/bintree/bintree_findprevious.c

@@ -1,67 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_findprevious.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation searches the specified "tree" for a "clientnode" which is
- * the one which logically preceeds the specified "key"
- *
- * A "clientnode" with the specified "key" doesn't need to be in the tree.
- *
- * tree - the "tree" instance to invoke this operation upon
- * key  - the "key" to search with
- *
- * RETURNS
- * "clientnode" instance or NULL if no node is found.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:33:12 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 27-Feb-2004		Graeme McKerrell	
- *    Fixed to account for empty tree
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new node,key comparison ordering
- * 28-Jan-2004		Graeme McKerrell	
- *   Initial verison 
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void *lub_bintree_findprevious(lub_bintree_t * this, const void *clientkey)
-{
-	lub_bintree_node_t *t = this->root;
-	int comp;
-
-	/*
-	 * have a look for a direct match
-	 */
-	t = this->root = lub_bintree_splay(this, t, clientkey);
-
-	if (NULL != t) {
-		/* now look at what we have got */
-		comp = lub_bintree_compare(this, t, clientkey);
-		if (comp >= 0) {
-			/*
-			 * time to fiddle with the left hand side of the tree
-			 * we need the closest node from the left hand side
-			 */
-			t = t->left =
-			    lub_bintree_splay(this, t->left, clientkey);
-		}
-	}
-	if (NULL == t) {
-		return NULL;
-	} else {
-		return lub_bintree_getclientnode(this, t);
-	}
-}
-
-/*--------------------------------------------------------- */

+ 0 - 52
lub/bintree/bintree_init.c

@@ -1,52 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_init.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operations initialise an instance of a binary tree at runtime.
- *
- * this       - the "tree" instance to initialise
- *
- * offset     - the offset of the node structure within the clients
- *              structure. This is typically passed using the offsetof() macro.
- *
- * compareFn  - a comparison function for comparing a "clientnode"
- *              with a "clientkey"
- *
- * getkeyFn   - a function which will fill out a "key" from a clientnode
- *
- * RETURNS
- * none
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 09:54:37 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 9-Feb-2004		Graeme McKerrell	
- *    update to remove spurious key_storage parameter
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void
-lub_bintree_init(lub_bintree_t * this,
-		 size_t node_offset,
-		 lub_bintree_compare_fn compareFn,
-		 lub_bintree_getkey_fn getkeyFn)
-{
-	this->root = NULL;
-	this->node_offset = node_offset;
-	this->compareFn = compareFn;
-	this->getkeyFn = getkeyFn;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 103
lub/bintree/bintree_insert.c

@@ -1,103 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_insert.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation adds a client node to the specified tree.
- *
- * tree       - the "tree" instance to invoke this operation upon
- * clientnode - a pointer to a client node. NB the tree can find the
- *              necessary util_BintreeNodeT from it's stored offset.
- *
- * RETURNS
- * 0 if the "clientnode" is added correctly to the tree.
- * 
- * If another "clientnode" already exists in the tree with the same key, then
- * -1 is returned, and the tree remains unchanged.
- *
- * If the "clientnode" had not been initialised, then an assert will fire.
- * 
- * If the bintree "node" is already part of a tree, then an assert will fire.
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:05:11 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 2-Mar-2004		Graeme McKerrell	
- *    fixed so that the insertion order is correct
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use the new getkey prototype and new node, key ordering
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include <assert.h>
-#include "private.h"
-
-/*--------------------------------------------------------- */
-int lub_bintree_insert(lub_bintree_t * this, void *clientnode)
-{
-	int result = -1;
-	lub_bintree_node_t *new;
-	lub_bintree_key_t key;
-
-	assert(clientnode);
-	if (NULL != clientnode) {
-		/* obtain the control block from the clientnode */
-		new = lub_bintree_getnode(this, clientnode);
-
-		/* check this node is not currently in another tree */
-		assert(new->left == NULL);
-		assert(new->right == NULL);
-
-		/* add this node to the splay tree */
-
-		/* Insert "node" into the tree , unless it's already there. */
-		if (NULL == this->root) {
-			this->root = new;
-			this->root->left = this->root->right = NULL;
-			result = 0;
-		} else {
-			int comp;
-			/* get a key from the node */
-			this->getkeyFn(clientnode, &key);
-
-			/* do the biz */
-			this->root = lub_bintree_splay(this, this->root, &key);
-
-			/*
-			 * compare the new key with the detail found
-			 * in the tree
-			 */
-			comp = lub_bintree_compare(this, this->root, &key);
-			if (comp > 0) {
-				new->left = this->root->left;
-				new->right = this->root;
-				this->root->left = NULL;
-				result = 0;
-			} else if (comp < 0) {
-				new->right = this->root->right;
-				new->left = this->root;
-				this->root->right = NULL;
-				result = 0;
-			} else {
-				/* We get here if it's already in the tree */
-			}
-		}
-		if (0 == result) {
-			/* update the tree root */
-			this->root = new;
-		}
-	}
-	/* added OK */
-	return result;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 56
lub/bintree/bintree_iterator_init.c

@@ -1,56 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_iterator_init.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation initialises an iterator. This can then be
- * subsequently used for iterating through a tree. This will work
- * even if the "clientnode" which defined the current iterator has been
- * removed before the next iterator operation.
- *
- * iter       - the iterator instance to initialise
- * tree       - the tree to associate with this iterator
- * clientnode - the starting point for the iteration
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:33:42 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 3-Nov-2004		Graeme McKerrell	
- *    Added key bounds checking code
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new getkey prototype
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-#include <assert.h>
-
-#define MAGIC_NUMBER 0x12345678
-/*--------------------------------------------------------- */
-void
-lub_bintree_iterator_init(lub_bintree_iterator_t * this,
-			  lub_bintree_t * tree, const void *clientnode)
-{
-	if (clientnode != NULL) {
-		this->tree = tree;
-		this->key.magic = MAGIC_NUMBER;
-		/* fill out the iterator's key */
-		this->tree->getkeyFn(clientnode, &this->key);
-		/*
-		 * this assert will fire if the client tries to store more than 
-		 * the current storage permits
-		 */
-		assert(this->key.magic == MAGIC_NUMBER);
-	}
-}
-
-/*--------------------------------------------------------- */

+ 0 - 43
lub/bintree/bintree_iterator_next.c

@@ -1,43 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_iterator_next.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation returns the next "clientnode" in an iteration.
- *
- * iter - the iterator instance to invoke this operation upon.
- *
- * RETURNS
- * "clientnode" instance or NULL if the iteration has reached the end of the
- * tree.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:34:26 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
-* 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
-  * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new key structure
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void *lub_bintree_iterator_next(lub_bintree_iterator_t * this)
-{
-	void *clientnode = lub_bintree_findnext(this->tree, &this->key);
-
-	/* make sure that next time we've move onward */
-	lub_bintree_iterator_init(this, this->tree, clientnode);
-
-	return clientnode;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 43
lub/bintree/bintree_iterator_previous.c

@@ -1,43 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_iterator_previous.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation returns the previous "clientnode" in an iteration.
- *
- * iter - the iterator instance to invoke this operation upon.
- *
- * RETURNS
- * "clientnode" instance or NULL if the iteration has reached the beginning
- * of the tree.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:35:19 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new key structure
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void *lub_bintree_iterator_previous(lub_bintree_iterator_t * this)
-{
-	void *clientnode = lub_bintree_findprevious(this->tree, &this->key);
-
-	/* make sure that next time we've move onward */
-	lub_bintree_iterator_init(this, this->tree, clientnode);
-
-	return clientnode;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 44
lub/bintree/bintree_node_init.c

@@ -1,44 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_node_init.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation is called to initialise a "clientnode" ready for
- * insertion into a tree. This is only required once after the memory
- * for a node has been allocated.
- *
- * tree       - the tree instance to invoke this operation upon
- * clientnode - the node to initialise.
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 09:57:06 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
-  * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 27-Feb-2004		Graeme McKerrell	
- *    Updated to simplify the initialisation of nodes
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include <assert.h>
-
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void lub_bintree_node_init(lub_bintree_node_t * node)
-{
-	assert(node);
-	if (node) {
-		node->left = NULL;
-		node->right = NULL;
-	}
-}
-
-/*--------------------------------------------------------- */

+ 0 - 81
lub/bintree/bintree_remove.c

@@ -1,81 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_remove.c
- *---------------------------------------------------------------
- * Description
- * ===========
- * This operation removes a "node" from the specified "tree"
- *
- * tree       - the "tree" instance to invoke this operation upon
- * clientnode - the node to remove
- *
- * RETURNS
- *   none
- *
- * POST CONDITIONS
- * The "node" will no longer be part of the specified tree, and can be
- * subsequently re-inserted
- *
- * If the node is not present in the specified tree, then an assert
- * will fire.
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 10:06:58 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 27-Dec-2004		Graeme McKerrell	
- *    added assert to catch removal of invalid node 
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
-  * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 23-Mar-2004		Graeme McKerrell	
- *    fixed to ensure that control block is re-initialised.
- * 16-Mar-2004		Graeme McKerrell	
- *    removed assert.
- * 27-Feb-2004		Graeme McKerrell	
- *    removed spurious call to node_init
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new node,key comparison ordering
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include <assert.h>
-
-#include "private.h"
-
-/*--------------------------------------------------------- */
-void lub_bintree_remove(lub_bintree_t * this, void *clientnode)
-{
-	lub_bintree_node_t *x, *t;
-	lub_bintree_key_t key;
-	int comp;
-
-	/* get the key from the node */
-	this->getkeyFn(clientnode, &key);
-
-	/* bring the node in question to the root of the tree */
-	t = lub_bintree_splay(this, this->root, &key);
-
-	/* check that the node was there to remove */
-	comp = lub_bintree_compare(this, t, &key);
-
-	assert(0 == comp);
-	if (0 == comp) {
-		if (t->left == NULL) {
-			x = t->right;
-		} else {
-			x = lub_bintree_splay(this, t->left, &key);
-			x->right = t->right;
-		}
-		/* set the new root */
-		this->root = x;
-
-		/* re-initialise the node control block for re-use */
-		lub_bintree_node_init(lub_bintree_getnode(this, clientnode));
-	}
-}
-
-/*--------------------------------------------------------- */

+ 0 - 130
lub/bintree/bintree_splay.c

@@ -1,130 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : bintree_splay.c
- *---------------------------------------------------------------
- * Description
- * ===========
- *              An implementation of top-down splaying
- *                  D. Sleator <sleator@cs.cmu.edu>
- *  	                     March 1992
- *
- * "Splay trees", or "self-adjusting search trees" are a simple and
- * efficient data structure for storing an ordered set.  The data
- * structure consists of a binary tree, without parent pointers, and
- * no additional fields.  It allows searching, insertion, deletion,
- * deletemin, deletemax, splitting, joining, and many other
- * operations, all with amortized logarithmic performance.  Since the
- * trees adapt to the sequence of requests, their performance on real
- * access patterns is typically even better.  Splay trees are
- * described in a number of texts and papers [1,2,3,4,5].
- *
- * The code here is adapted from simple top-down splay, at the bottom
- * of page 669 of [3].  It can be obtained via anonymous ftp from
- * spade.pc.cs.cmu.edu in directory /usr/sleator/public.
- * 
- * The chief modification here is that the splay operation works even
- * if the item being splayed is not in the tree, and even if the tree
- * root of the tree is NULL.  So the line:
- *
- *                            t = splay(i, t);
- *
- * causes it to search for item with key i in the tree rooted at t.
- * If it's there, it is splayed to the root.  If it isn't there,
- * then the node put at the root is the last one before NULL that
- * would have been reached in a normal binary search for i.  (It's a
- * neighbor of i in the tree.)  This allows many other operations to
- * be easily implemented, as shown below.
- *
- * [1] "Fundamentals of data structures in C", Horowitz, Sahni,
- *      and Anderson-Freed, Computer Science Press, pp 542-547.
- * [2] "Data Structures and Their Algorithms", Lewis and Denenberg,
- *      Harper Collins, 1991, pp 243-251.
- * [3] "Self-adjusting Binary Search Trees" Sleator and Tarjan,
- *     JACM Volume 32, No 3, July 1985, pp 652-686.
- * [4] "Data Structure and Algorithm Analysis", Mark Weiss,
- *      Benjamin Cummins, 1992, pp 119-130.
- * [5] "Data Structures, Algorithms, and Performance", Derick Wood,
- *      Addison-Wesley, 1993, pp 367-375.
- *
- * The following code was written by Daniel Sleator, and is released
- * in the public domain.
- *
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 16:29:28 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 2-Mar-2004		Graeme McKerrell	
- *    Fixed to account for comparision logic being (node - key)
- *    original algorithm expected (key - node)
- * 9-Feb-2004		Graeme McKerrell	
- *    updated to use new node,key comparison ordering
- * 28-Jan-2004		Graeme McKerrell	
- *    Adapted from original public domain code
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "private.h"
-
-/*--------------------------------------------------------- */
-lub_bintree_node_t *lub_bintree_splay(const lub_bintree_t * this,
-				      lub_bintree_node_t * t, const void *key)
-{
-	/* Simple top down splay, not requiring "key" to be in the tree t.  */
-	/* What it does is described above.                                 */
-	lub_bintree_node_t N, *leftTreeMax, *rightTreeMin, *y;
-	int comp;
-
-	if (t == NULL)
-		return t;
-	N.left = N.right = NULL;
-	leftTreeMax = rightTreeMin = &N;
-
-	for (;;) {
-		comp = lub_bintree_compare(this, t, key);
-		if (comp > 0) {
-			if (t->left == NULL)
-				break;
-			if (lub_bintree_compare(this, t->left, key) > 0) {
-				y = t->left;	/* rotate right */
-				t->left = y->right;
-				y->right = t;
-				t = y;
-				if (t->left == NULL)
-					break;
-			}
-			rightTreeMin->left = t;	/* link right */
-			rightTreeMin = t;
-			t = t->left;
-		} else if (comp < 0) {
-			if (t->right == NULL)
-				break;
-			if (lub_bintree_compare(this, t->right, key) < 0) {
-				y = t->right;	/* rotate left */
-				t->right = y->left;
-				y->left = t;
-				t = y;
-				if (t->right == NULL)
-					break;
-			}
-			leftTreeMax->right = t;	/* link left */
-			leftTreeMax = t;
-			t = t->right;
-		} else {
-			break;
-		}
-	}
-	leftTreeMax->right = t->left;	/* assemble */
-	rightTreeMin->left = t->right;
-	t->left = N.right;
-	t->right = N.left;
-
-	/* return the new root */
-	return t;
-}
-
-/*--------------------------------------------------------- */

+ 0 - 17
lub/bintree/module.am

@@ -1,17 +0,0 @@
-## Process this file with automake to produce Makefile.in
-liblub_la_SOURCES      +=   lub/bintree/bintree_dump.c              \
-                            lub/bintree/bintree_find.c              \
-                            lub/bintree/bintree_findfirst.c         \
-                            lub/bintree/bintree_findlast.c          \
-                            lub/bintree/bintree_findnext.c          \
-                            lub/bintree/bintree_findprevious.c      \
-                            lub/bintree/bintree_init.c              \
-                            lub/bintree/bintree_insert.c            \
-                            lub/bintree/bintree_iterator_init.c     \
-                            lub/bintree/bintree_iterator_next.c     \
-                            lub/bintree/bintree_iterator_previous.c \
-                            lub/bintree/bintree_node_init.c         \
-                            lub/bintree/bintree_remove.c            \
-                            lub/bintree/bintree_splay.c             \
-                            lub/bintree/private.h
-

+ 0 - 71
lub/bintree/private.h

@@ -1,71 +0,0 @@
-/*********************** -*- Mode: C -*- ***********************
- * File            : private.h
- *---------------------------------------------------------------
- * Description
- * ===========
- * This defines the private interface used internally by this component
- *---------------------------------------------------------------
- * Author          : Graeme McKerrell
- * Created On      : Wed Jan 28 08:45:01 2004
- * Status          : TESTED
- *---------------------------------------------------------------
- * HISTORY
- * 7-Dec-2004		Graeme McKerrell	
- *    Renamed to the "lub_" namespace
- * 5-May-2004		Graeme McKerrell	
- *    updates following review
- * 9-Feb-2004		Graeme McKerrell	
- *    modified compare MACRO
- * 28-Jan-2004		Graeme McKerrell	
- *    Initial version
- *---------------------------------------------------------------
- * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
- **************************************************************** */
-#include "lub/bintree.h"
-
-/*************************************************************
- * PRIVATE OPERATIONS
- ************************************************************* */
-/*------------------------------------------------------------ */
-/* This is the operation which performs a top-down splay. It is
- * the core workhorse for this tree implementation.
- *
- * tree - the instance to invoke this operation upon
- * t    - the root node to splay to.
- * key  - the value with which to splay
- */
-extern lub_bintree_node_t *lub_bintree_splay(const lub_bintree_t * tree,
-					     lub_bintree_node_t * t,
-					     const void *key);
-/*------------------------------------------------------------ */
-/* This operation converts a "node" into a "clientnode"
- * subtracting the offset gives the base pointer to the node
- *
- * this - the tree to invoke this operation upon
- * node - the node to convert
- */
-#define lub_bintree_getclientnode(this,node)\
-(void *)(((char*)node) - this->node_offset)
-/*------------------------------------------------------------ */
-/* This operation converts a "clientnode" into a "node"
- * adding the offset gives the base pointer to the node
- *
- * this       - the tree to invoke this operation upon
- * clientnode - the clientnode to convert
- */
-#define lub_bintree_getnode(this,clientnode)\
-(lub_bintree_node_t *)(((char*)clientnode) + this->node_offset)	/*lint -e826 */
-/*------------------------------------------------------------ */
-/* This operation compares a key with a "node"
- * it returns
- * <0 if key <  node
- *  0 if key == node
- * >0 if key >  node
- *
- * this - the tree to invoke this operation upon
- * node - the "node" to compare
- * key  - the key to compare
- */
-#define lub_bintree_compare(this,node,key)\
-(this)->compareFn(lub_bintree_getclientnode(this,node),key)
-/*------------------------------------------------------------ */

+ 9 - 7
lub/c_decl.h

@@ -1,18 +1,20 @@
-/* 
- * c_decl.h 
- * 
+/*
+ * c_decl.h
+ *
  * a simple set of macros to ease declaration of C interfaces.
  */
- /**
+
+///@{
+/**
 \ingroup lub
 \defgroup lub_c_decl C linkage macros
-@{
+
 These two macros are used to simplify the declaration of C-linkage code.
 Rather than worry about preprocessor directives similar to
 \code
 #ifdef __cplusplus
 extern "C" {
-#endif 
+#endif
 
 int foobar(void);
 
@@ -43,5 +45,5 @@ _END_C_DECL
 #define _END_C_DECL
 #endif				/* not __cplusplus */
 
-/** @} */
+/// /** @} */
 #endif				/* _lub_c_decl_h */

lub/string.h → lub/str.h


lub/string/module.am → lub/str/module.am


lub/string/private.h → lub/str/private.h


+ 17 - 3
lub/string/string.c

@@ -1,6 +1,7 @@
-/*
- * string.c
+/** @file string.c
+ * About this file2
  */
+
 #include "private.h"
 
 #include <stdlib.h>
@@ -12,7 +13,19 @@ const char *lub_string_esc_default = "`|$<>&()#;\\\"!";
 const char *lub_string_esc_regex = "^$.*+[](){}";
 const char *lub_string_esc_quoted = "\\\"";
 
-/*--------------------------------------------------------- */
+auf_str_free()
+auf_string_free()
+faux_str_free()
+faux_string_free()
+
+/** @brief Free the memory allocated for the string.
+ *
+ * Safely free the memory allocated for the string. You can use NULL
+ * pointer with this function. POSIX's free() checks for the NULL pointer
+ * but not all systems do so.
+ *
+ * @param [in] ptr Pointer to allocated string
+ */
 void lub_string_free(char *ptr)
 {
 	if (!ptr)
@@ -20,6 +33,7 @@ void lub_string_free(char *ptr)
 	free(ptr);
 }
 
+
 /*--------------------------------------------------------- */
 char *lub_string_ndecode(const char *string, unsigned int len)
 {