diff options
author | Christopher R. Hertel <crh@samba.org> | 1998-03-10 15:39:41 +0000 |
---|---|---|
committer | Christopher R. Hertel <crh@samba.org> | 1998-03-10 15:39:41 +0000 |
commit | 87d4fc1d225ab0aa5bac2b104d7958065a453144 (patch) | |
tree | 2d741498eb38ad36c46621cbaef111490effd590 /source3/ubiqx/ubi_dLinkList.c | |
parent | c0b06785c11eca0e037febfe887ce9dbb776d4e4 (diff) | |
download | samba-87d4fc1d225ab0aa5bac2b104d7958065a453144.tar.gz samba-87d4fc1d225ab0aa5bac2b104d7958065a453144.tar.bz2 samba-87d4fc1d225ab0aa5bac2b104d7958065a453144.zip |
Updates to all of these base level modules.
Trees: Previously, the AVL node type was different than the node type used
in the BinTree and SplayTree modules. It requires an additional
field to maintain AVL balance information. I merged that field into
the base type (in ubi_BinTree.h) so that all three use the same
node type. On most systems this will have zero effect on the node
size, due to word alignment. The change allowed me to remove a
bigbunch of redundant code, which makes the AVL module smaller and
cleaner.
Linked Lists: I combined ubi_StackQueue into ubi_sLinkList. The interface
has changed a tiny bit. I added macros to ubi_dLinkList to round
it out a bit.
I have verified that the few Samba modules that use these tools (so far)
do not have any problems with the changes.
Chris -)-----
(This used to be commit 599a29401defded32358dfae18e54704c0428f38)
Diffstat (limited to 'source3/ubiqx/ubi_dLinkList.c')
-rw-r--r-- | source3/ubiqx/ubi_dLinkList.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/source3/ubiqx/ubi_dLinkList.c b/source3/ubiqx/ubi_dLinkList.c index 5d970a9ca1..c903dcbc04 100644 --- a/source3/ubiqx/ubi_dLinkList.c +++ b/source3/ubiqx/ubi_dLinkList.c @@ -1,7 +1,7 @@ /* ========================================================================== ** * ubi_dLinkList.c * - * Copyright (C) 1997 by Christopher R. Hertel + * Copyright (C) 1997, 1998 by Christopher R. Hertel * * Email: crh@ubiqx.mn.org * -------------------------------------------------------------------------- ** @@ -24,6 +24,13 @@ * * -------------------------------------------------------------------------- ** * + * Log: ubi_dLinkList.c,v + * Revision 0.5 1998/03/10 02:55:00 crh + * Simplified the code and added macros for stack & queue manipulations. + * + * Revision 0.4 1998/01/03 01:53:56 crh + * Added ubi_dlCount() macro. + * * Revision 0.3 1997/10/15 03:05:39 crh * Added some handy type casting to the macros. Added AddHere and RemThis * macros. @@ -35,11 +42,16 @@ * Revision 0.1 1997/10/07 04:34:07 crh * Initial Revision. * + * -------------------------------------------------------------------------- ** + * This module is similar to the ubi_sLinkList module, but it is neither a + * descendant type nor an easy drop-in replacement for the latter. One key + * difference is that the ubi_dlRemove() function removes the indicated node, + * while the ubi_slRemove() function (in ubi_sLinkList) removes the node + * *following* the indicated node. * * ========================================================================== ** */ -#include "../includes.h" #include "ubi_dLinkList.h" /* ========================================================================== ** @@ -85,28 +97,17 @@ ubi_dlNodePtr ubi_dlInsert( ubi_dlListPtr ListPtr, * ------------------------------------------------------------------------ ** */ { - if( NULL == After ) - { - New->Next = ListPtr->Head; - New->Prev = NULL; - if( NULL != ListPtr->Head ) - ListPtr->Head->Prev = New; - else - ListPtr->Tail = New; - ListPtr->Head = New; - } + ubi_dlNodePtr PredNode = After ? After : (ubi_dlNodePtr)ListPtr; + + New->Next = PredNode->Next; + New->Prev = After; + PredNode->Next = New; + if( New->Next ) + New->Next->Prev = New; else - { - New->Next = After->Next; - New->Prev = After; - if( NULL != After->Next ) - After->Next->Prev = New; - else - ListPtr->Tail = New; - After->Next = New; - } + ListPtr->Tail = New; - ++(ListPtr->count); + (ListPtr->count)++; return( New ); } /* ubi_dlInsert */ @@ -125,7 +126,7 @@ ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old ) * ------------------------------------------------------------------------ ** */ { - if( NULL != Old ) + if( Old ) { if( Old->Next ) Old->Next->Prev = Old->Prev; @@ -137,11 +138,10 @@ ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old ) else ListPtr->Head = Old->Next; - --(ListPtr->count); + (ListPtr->count)--; } return( Old ); } /* ubi_dlRemove */ - /* ================================ The End ================================= */ |