1
/*****************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 2002, Daniel Stenberg, <daniel@haxx.se>, et al
10
* In order to be useful for every potential user, curl and libcurl are
11
* dual-licensed under the MPL and the MIT/X-derivate licenses.
13
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
14
* copies of the Software, and permit persons to whom the Software is
15
* furnished to do so, under the terms of the MPL or the MIT/X-derivate
16
* licenses. You may pick one of these licenses.
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
* KIND, either express or implied.
21
* $Id: llist.c,v 1.3 2002/02/17 14:55:35 bagder Exp $
22
*****************************************************************************/
32
/* this must be the last include file */
36
curl_llist_init(curl_llist *l, curl_llist_dtor dtor)
45
curl_llist_alloc(curl_llist_dtor dtor)
49
list = (curl_llist *)malloc(sizeof(curl_llist));
53
curl_llist_init(list, dtor);
59
curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p)
61
curl_llist_element *ne;
63
ne = (curl_llist_element *) malloc(sizeof(curl_llist_element));
65
if (list->size == 0) {
67
list->head->prev = NULL;
68
list->head->next = NULL;
87
curl_llist_insert_prev(curl_llist *list, curl_llist_element *e, const void *p)
89
curl_llist_element *ne;
91
ne = (curl_llist_element *) malloc(sizeof(curl_llist_element));
93
if (list->size == 0) {
95
list->head->prev = NULL;
96
list->head->next = NULL;
114
curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user)
116
if (e == NULL || list->size == 0)
119
if (e == list->head) {
120
list->head = e->next;
122
if (list->head == NULL)
125
e->next->prev = NULL;
127
e->prev->next = e->next;
129
list->tail = e->prev;
131
e->next->prev = e->prev;
134
list->dtor(user, e->ptr);
142
curl_llist_remove_next(curl_llist *list, curl_llist_element *e, void *user)
144
return curl_llist_remove(list, e->next, user);
148
curl_llist_remove_prev(curl_llist *list, curl_llist_element *e, void *user)
150
return curl_llist_remove(list, e->prev, user);
154
curl_llist_count(curl_llist *list)
160
curl_llist_destroy(curl_llist *list, void *user)
162
while (list->size > 0) {
163
curl_llist_remove(list, CURL_LLIST_TAIL(list), user);