n_Name
field in a Node structure (which you use to name a node), tasks perform all normal operations involving lists by using the function calls described in this chapter.
Name
field lets you easily locate any node in a linked list.Example 1: The Node data structure.
typedef struct Node
{
struct Node *n_Next; /* pointer to next node in list */
struct Node *n_Prev; /* pointer to previous node in list */
uint8 n_SubsysType; /* what folio manages this node */
uint8 n_Type; /* what type of node for the folio */
uint8 n_Priority; /* queueing priority */
uint8 n_Flags; /* flags used by the system */
int32 n_Size; /* total size of node including hdr */
char *n_Name; /* ptr to null terminated string or
NULL */
} Node, *NodeP;
/* n_Flag bits */
/* bits 4-7 are reserved for the system */
/* bits 0-3 are available for node specific use by the system */
#define NODE_RSRV1 0x40
#define NODE_SIZELOCKED 0x20 /* The size of this item has been
/* locked down */
#define NODE_ITEMVALID 0x10 /* This is an ItemNode */
#define NODE_NAMEVALID 0x80 /* This node's namefield is valid */
The NamelessNode structure is identical to the Node structure, except that it doesn't have the n_Name field
. You can use the NamelessNode structure in place of a Node structure for all the functions and macros explained in this chapter, except for the FindNamedNode()
and DumpNode()
functions. Since these functions use the n_Name
field, they cannot handle the NamelessNode.
Example 2: The NamelessNode structure.
The MinNode structure is very small, and provides just enough information to link within lists. It can be used with most functions and macros explained in this chapter, except for
/* Node structure used when the Name is not needed */
typedef struct NamelessNode
{
struct NamelessNode *n_Next;
struct NamelessNode *n_Prev;
uint8 n_SubsysType;
uint8 n_Type;
uint8 n_Priority;
uint8 n_Flags;
int32 n_Size;
} NamelessNode, *NamelessNodeP;
SetNodePri()
, InsertNodeFromTail()
, InsertNodeFromHead()
, FindNamedNode()
, and DumpNode()
. These functions use the extra fields found in the Node structure, and cannot work with the simple MinNode structure.
Example 3: The MinNode structure.
/* Node structure used for linking only */
typedef struct MinNode
{
struct MinNode *n_Next;
struct MinNode *n_Prev;
} MinNode;
Example 4: The List data structure.
typedef struct List
{
Node l; /* A list is a node itself */
ListAnchor ListAnchor; /* Anchor point for list of nodes */
} List, *ListP;
Example 5: The ListAnchor union.
typedef union ListAnchor
{
struct /* ptr to first node */
{ /* anchor for lastnode */
Link links;
Link *filler;
} head;
struct
{
Link *filler;
Link links; /* ptr to lastnode */
} tail; /* anchore for firstnode */
} ListAnchor;
Example 6: The Link data structure.
typedef struct Link
{
struct Link *flink; /* forward (next) link */
struct Link *blink; /* backward (prev) link */
} Link;