[Libsysio-commit] HEAD: libsysio/src tree.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-08-31 21:35:56
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26922/src Modified Files: tree.c Log Message: The splay routine is now public, called _sysio_splay. Note, it's still a really bad idea to depend on the other tree routines maintaining their trees as a splay-tree. Index: tree.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/tree.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- tree.c 17 Apr 2009 14:54:35 -0000 1.3 +++ tree.c 31 Aug 2009 21:35:45 -0000 1.4 @@ -52,8 +52,8 @@ * Returns the value from the last compare; The one that brought, or left, * the root node at return. */ -static int -splay(const void *key, +int +_sysio_splay(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)) { @@ -120,7 +120,7 @@ _sysio_tree_search(struct tree_node *tn, if (!*rootp) { tn->tn_left = tn->tn_right = NULL; } else { - i = splay(tn->tn_key, rootp, compar); + i = _sysio_splay(tn->tn_key, rootp, compar); if (i < 0) { tn->tn_left = (*rootp)->tn_left; tn->tn_right = *rootp; @@ -147,7 +147,7 @@ _sysio_tree_find(const void *key, if (!*rootp) return NULL; - return splay(key, rootp, compar) == 0 ? *rootp : NULL; + return _sysio_splay(key, rootp, compar) == 0 ? *rootp : NULL; } /* @@ -169,7 +169,7 @@ _sysio_tree_delete(const void *key, if (!(*rootp)->tn_left) *rootp = (*rootp)->tn_right; else { - splay((*rootp)->tn_key, &(*rootp)->tn_left, compar); + _sysio_splay((*rootp)->tn_key, &(*rootp)->tn_left, compar); (*rootp)->tn_left->tn_right = (*rootp)->tn_right; *rootp = (*rootp)->tn_left; } |