File: list.h

package info (click to toggle)
scanmem 0.07-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 624 kB
  • ctags: 229
  • sloc: ansic: 2,176; sh: 985; exp: 342; makefile: 8
file content (40 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*

 $Id: list.h,v 1.9 2007-06-05 01:45:35+01 taviso Exp $
 A very simple linked list implementation.

*/

#ifndef _LIST_INC
#define _LIST_INC

typedef struct element {
    void *data;
    struct element *next;
} element_t;

typedef struct {
    unsigned size;
    element_t *head;
    element_t *tail;
} list_t;

/* create a new list */
list_t *l_init(void);

/* destroy the whole list */
void l_destroy(list_t * list);

/* add a new element to the list */
int l_append(list_t * list, element_t * element, void *data);

/* remove the element at element->next */
void l_remove(list_t * list, element_t * element, void **data);

/* remove the nth element from head */
void l_remove_nth(list_t * list, unsigned n, void **data);

/* remove all elements from *src, and append to dst */
int l_concat(list_t *dst, list_t **src);

#endif