libUPnP 1.14.19
LinkedList.h
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * * Neither name of Intel Corporation nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 ******************************************************************************/
31
32#ifndef LINKED_LIST_H
33#define LINKED_LIST_H
34
39#include "FreeList.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#define EOUTOFMEM (-7 & 1 << 29)
46
47#define FREELISTSIZE 100
48#define LIST_SUCCESS 1
49#define LIST_FAIL 0
50
52typedef void (*free_function)(void *arg);
53
55typedef int (*cmp_routine)(void *itemA, void *itemB);
56
60typedef struct LISTNODE
61{
62 struct LISTNODE *prev;
63 struct LISTNODE *next;
64 void *item;
66
98
106int ListInit(
108 LinkedList *list,
110 cmp_routine cmp_func,
112 free_function free_func);
113
125 LinkedList *list,
127 void *item);
128
139 LinkedList *list,
141 void *item);
142
153 LinkedList *list,
155 void *item,
157 ListNode *bnode);
158
169 LinkedList *list,
171 void *item,
173 ListNode *anode);
174
183void *ListDelNode(
185 LinkedList *list,
187 ListNode *dnode,
190 int freeItem);
191
200int ListDestroy(
202 LinkedList *list,
205 int freeItem);
206
216 LinkedList *list);
217
227 LinkedList *list);
228
238 LinkedList *list,
240 ListNode *node);
241
252 LinkedList *list,
254 ListNode *node);
255
268 LinkedList *list,
270 ListNode *start,
272 void *item);
273
281long ListSize(
283 LinkedList *list);
284
285#ifdef __cplusplus
286}
287#endif
288
289#endif /* LINKED_LIST_H */
long ListSize(LinkedList *list)
Returns the size of the list.
Definition LinkedList.c:301
int ListDestroy(LinkedList *list, int freeItem)
Removes all memory associated with list nodes. Does not free LinkedList *list.
Definition LinkedList.c:200
ListNode * ListPrev(LinkedList *list, ListNode *node)
Returns the previous item in the list.
Definition LinkedList.c:258
void * ListDelNode(LinkedList *list, ListNode *dnode, int freeItem)
Removes a node from the list. The memory for the node is freed.
Definition LinkedList.c:177
void(* free_function)(void *arg)
Definition LinkedList.h:52
ListNode * ListAddBefore(LinkedList *list, void *item, ListNode *anode)
Adds a node before the specified node. Node gets added immediately before anode.
Definition LinkedList.c:153
ListNode * ListNext(LinkedList *list, ListNode *node)
Returns the next item in the list.
Definition LinkedList.c:245
struct LINKEDLIST LinkedList
ListNode * ListAddAfter(LinkedList *list, void *item, ListNode *bnode)
Adds a node after the specified node. Node gets added immediately after bnode.
Definition LinkedList.c:129
ListNode * ListHead(LinkedList *list)
Returns the head of the list.
Definition LinkedList.c:219
ListNode * ListAddHead(LinkedList *list, void *item)
Adds a node to the head of the list. Node gets immediately after list head.
Definition LinkedList.c:109
ListNode * ListAddTail(LinkedList *list, void *item)
Adds a node to the tail of the list. Node gets added immediately before list.tail.
Definition LinkedList.c:119
struct LISTNODE ListNode
ListNode * ListTail(LinkedList *list)
Returns the tail of the list.
Definition LinkedList.c:232
ListNode * ListFind(LinkedList *list, ListNode *start, void *item)
Finds the specified item in the list.
Definition LinkedList.c:272
int ListInit(LinkedList *list, cmp_routine cmp_func, free_function free_func)
Initializes LinkedList. Must be called first and only once for List.
Definition LinkedList.c:83
int(* cmp_routine)(void *itemA, void *itemB)
Definition LinkedList.h:55
Definition FreeList.h:62
Definition LinkedList.h:84
cmp_routine cmp_func
Definition LinkedList.h:96
ListNode tail
Definition LinkedList.h:88
FreeList freeNodeList
Definition LinkedList.h:92
free_function free_func
Definition LinkedList.h:94
long size
Definition LinkedList.h:90
ListNode head
Definition LinkedList.h:86
Definition LinkedList.h:61