mirror of
https://github.com/samba-team/samba.git
synced 2025-03-03 12:58:35 +03:00
To each list type, I added a macro that makes it easier to define and
initialize a list header.
This commit is contained in:
parent
a2a9f55a76
commit
3c133778f1
@ -24,7 +24,10 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_dLinkList.c,v
|
||||
* Log: ubi_dLinkList.c,v
|
||||
* Revision 0.10 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_dlNewList() macro.
|
||||
*
|
||||
* Revision 0.9 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
|
@ -26,7 +26,10 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_dLinkList.h,v
|
||||
* Log: ubi_dLinkList.h,v
|
||||
* Revision 0.10 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_dlNewList() macro.
|
||||
*
|
||||
* Revision 0.9 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
@ -101,6 +104,13 @@ typedef ubi_dlList *ubi_dlListPtr;
|
||||
/* ========================================================================== **
|
||||
* Macros...
|
||||
*
|
||||
* ubi_dlNewList - Macro used to declare and initialize a new list in one
|
||||
* swell foop. It is used when defining a variable of
|
||||
* type ubi_dlList. The definition
|
||||
* static ubi_dlNewList( gerbil );
|
||||
* is translated to
|
||||
* static ubi_dlList gerbil[1] = {{ NULL, NULL, 0 }};
|
||||
*
|
||||
* ubi_dlCount - Return the number of entries currently in the list.
|
||||
*
|
||||
* ubi_dlAddHead - Add a new node at the head of the list.
|
||||
@ -128,11 +138,12 @@ typedef ubi_dlList *ubi_dlListPtr;
|
||||
* Add and Rem macros are nothing more than nice front-ends to the
|
||||
* Insert and Remove operations.
|
||||
*
|
||||
* Also note that there the First, Next and Last macros do no parameter
|
||||
* checking!
|
||||
* Also note that the First, Next and Last macros do no parameter checking!
|
||||
*
|
||||
*/
|
||||
|
||||
#define ubi_dlNewList( L ) ubi_dlList (L)[1] = {{ NULL, NULL, 0 }}
|
||||
|
||||
#define ubi_dlCount( L ) (((ubi_dlListPtr)(L))->count)
|
||||
|
||||
#define ubi_dlAddHead( L, N ) \
|
||||
|
@ -24,7 +24,10 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_sLinkList.c,v
|
||||
* Log: ubi_sLinkList.c,v
|
||||
* Revision 0.9 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_slNewList() macro.
|
||||
*
|
||||
* Revision 0.8 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
@ -63,15 +66,20 @@
|
||||
* mind-numbingly simple, but I'm surprised by the number of programs out
|
||||
* there which re-implement this a dozen or so times.
|
||||
*
|
||||
* Notes: When the list header is initialized, the Tail pointer is set to
|
||||
* point to the Head pointer. This simplifies things a great deal,
|
||||
* except that you can't initialize a stack or queue by simply
|
||||
* zeroing it out. One sure way to initialize the header is to call
|
||||
* ubi_slInit(). Another option would be something like this:
|
||||
* Note: When the list header is initialized, the Tail pointer is set to
|
||||
* point to the Head pointer. This simplifies things a great deal,
|
||||
* except that you can't initialize a stack or queue by simply
|
||||
* zeroing it out. One sure way to initialize the header is to call
|
||||
* ubi_slInit(). Another option would be something like this:
|
||||
*
|
||||
* static ubi_slList MyList = { NULL, (ubi_slNodePtr)&MyList, 0 };
|
||||
* ubi_slNewList( MyList );
|
||||
*
|
||||
* See ubi_slInit() and the ubi_slList structure for more info.
|
||||
* Which translates to:
|
||||
*
|
||||
* ubi_slList MyList[1] = { NULL, (ubi_slNodePtr)MyList, 0 };
|
||||
*
|
||||
* See ubi_slInit(), ubi_slNewList(), and the ubi_slList structure
|
||||
* for more info.
|
||||
*
|
||||
* + Also, note that this module is similar to the ubi_dLinkList
|
||||
* module. There are three key differences:
|
||||
|
@ -26,7 +26,10 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
*
|
||||
* Log: ubi_sLinkList.h,v
|
||||
* Log: ubi_sLinkList.h,v
|
||||
* Revision 0.9 1998/07/24 07:30:20 crh
|
||||
* Added the ubi_slNewList() macro.
|
||||
*
|
||||
* Revision 0.8 1998/06/04 21:29:27 crh
|
||||
* Upper-cased defined constants (eg UBI_BINTREE_H) in some header files.
|
||||
* This is more "standard", and is what people expect. Weird, eh?
|
||||
@ -57,7 +60,7 @@
|
||||
* Initial Revision.
|
||||
*
|
||||
* -------------------------------------------------------------------------- **
|
||||
* This module implements a singly-linked list which may also be used as a
|
||||
* This module implements a singly-linked list which may also be used as a
|
||||
* queue or a stack. For a queue, entries are added at the tail and removed
|
||||
* from the head of the list. For a stack, the entries are entered and
|
||||
* removed from the head of the list. A traversal of the list will always
|
||||
@ -71,9 +74,14 @@
|
||||
* zeroing it out. One sure way to initialize the header is to call
|
||||
* ubi_slInit(). Another option would be something like this:
|
||||
*
|
||||
* static ubi_slList MyList = { NULL, (ubi_slNodePtr)&MyList, 0 };
|
||||
* ubi_slNewList( MyList );
|
||||
*
|
||||
* See ubi_slInit() and the ubi_slList structure for more info.
|
||||
* Which translates to:
|
||||
*
|
||||
* ubi_slList MyList[1] = { NULL, (ubi_slNodePtr)MyList, 0 };
|
||||
*
|
||||
* See ubi_slInit(), ubi_slNewList(), and the ubi_slList structure
|
||||
* for more info.
|
||||
*
|
||||
* + Also, note that this module is similar to the ubi_dLinkList
|
||||
* module. There are three key differences:
|
||||
@ -84,7 +92,7 @@
|
||||
* is not done in ubi_dLinkList.
|
||||
* - The ubi_slRemove() function, by necessity, removed the 'next'
|
||||
* node. In ubi_dLinkList, the ubi_dlRemove() function removes
|
||||
* the 'current' node.
|
||||
* the 'current' node.
|
||||
*
|
||||
* ========================================================================== **
|
||||
*/
|
||||
@ -117,9 +125,13 @@ typedef struct
|
||||
|
||||
typedef ubi_slList *ubi_slListPtr;
|
||||
|
||||
|
||||
/* ========================================================================== **
|
||||
* Macros...
|
||||
*
|
||||
* ubi_slNewList - Macro used to declare and initialize a list header in
|
||||
* one step.
|
||||
*
|
||||
* ubi_slCount - Returns the current number of entries in the list.
|
||||
*
|
||||
* ubi_slAddHead - Add a new node at the head of the list.
|
||||
@ -143,11 +155,12 @@ typedef ubi_slList *ubi_slListPtr;
|
||||
* Add and Rem macros are nothing more than nice front-ends to the
|
||||
* Insert and Remove functions.
|
||||
*
|
||||
* Also note that there the First, Next and Last macros do no parameter
|
||||
* checking!
|
||||
* Also note that the First, Next and Last macros do no parameter checking!
|
||||
*
|
||||
*/
|
||||
|
||||
#define ubi_slNewList( L ) ubi_slList (L)[1] = {{ NULL, (ubi_slNodePtr)(L), 0 }}
|
||||
|
||||
#define ubi_slCount( L ) (((ubi_slListPtr)(L))->count)
|
||||
|
||||
#define ubi_slAddHead( L, N ) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user