1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 Contains: interface to generic linked lists.
24 Change History (most recent first):
26 $Log: GenLinkedList.h,v $
27 Revision 1.3 2006/08/14 23:24:56 cheshire
28 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
30 Revision 1.2 2004/02/05 07:41:08 cheshire
35 #ifndef __GenLinkedList__
36 #define __GenLinkedList__
48 typedef struct GenLinkedList GenLinkedList
;
51 void InitLinkedList( GenLinkedList
*pList
, size_t linkOffset
);
53 void AddToHead( GenLinkedList
*pList
, void *elem
);
54 void AddToTail( GenLinkedList
*pList
, void *elem
);
56 int RemoveFromList( GenLinkedList
*pList
, void *elem
);
58 int ReplaceElem( GenLinkedList
*pList
, void *elemInList
, void *newElem
);
62 struct GenDoubleLinkedList
69 typedef struct GenDoubleLinkedList GenDoubleLinkedList
;
72 void InitDoubleLinkedList( GenDoubleLinkedList
*pList
, size_t fwdLinkOffset
,
73 size_t backLinkOffset
);
75 void DLLAddToHead( GenDoubleLinkedList
*pList
, void *elem
);
77 void DLLRemoveFromList( GenDoubleLinkedList
*pList
, void *elem
);
81 /* A GenLinkedOffsetList is like a GenLinkedList that stores the *Next field as a signed */
82 /* offset from the address of the beginning of the element, rather than as a pointer. */
84 struct GenLinkedOffsetList
90 typedef struct GenLinkedOffsetList GenLinkedOffsetList
;
93 void InitLinkedOffsetList( GenLinkedOffsetList
*pList
, size_t linkOffset
);
95 void *GetHeadPtr( GenLinkedOffsetList
*pList
);
96 void *GetTailPtr( GenLinkedOffsetList
*pList
);
97 void *GetOffsetLink( GenLinkedOffsetList
*pList
, void *elem
);
99 void OffsetAddToHead( GenLinkedOffsetList
*pList
, void *elem
);
100 void OffsetAddToTail( GenLinkedOffsetList
*pList
, void *elem
);
102 int OffsetRemoveFromList( GenLinkedOffsetList
*pList
, void *elem
);
104 int OffsetReplaceElem( GenLinkedOffsetList
*pList
, void *elemInList
, void *newElem
);
107 #endif // __GenLinkedList__