2 * list.c -- list utility functions
4 * Copyright (C) 2005, 2007 Michal Januszewski <spock@gentoo.org>
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License v2. See the file COPYING in the main directory of this archive for
15 void list_add(list
*l
, void *obj
)
17 if (l
->tail
!= NULL
) {
18 l
->tail
->next
= malloc(sizeof(item
));
19 l
->tail
->next
->p
= obj
;
20 l
->tail
->next
->next
= NULL
;
21 l
->tail
= l
->tail
->next
;
23 l
->head
= l
->tail
= malloc(sizeof(item
));
30 * Append an element to the end of the list while simultaneously discarding
33 void list_ringadd(list
*l
, void *obj
)
43 void list_free(list l
, bool free_item
)
47 for (i
= l
.head
; i
!= NULL
; ) {
58 void list_del(list
*l
, item
*prev
, item
*curr
)
61 prev
->next
= curr
->next
;