File: list.h

package info (click to toggle)
unicorn-engine 2.0.1.post1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,376 kB
  • sloc: ansic: 372,229; sh: 8,758; python: 7,951; java: 5,111; ruby: 4,162; pascal: 1,805; haskell: 1,379; cs: 424; makefile: 306; cpp: 298; asm: 52
file content (36 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (3)
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
#ifndef UC_LLIST_H
#define UC_LLIST_H

#include "unicorn/platform.h"

typedef void (*delete_fn)(void *data);

struct list_item {
    struct list_item *next;
    void *data;
};

struct list {
    struct list_item *head, *tail;
    delete_fn delete_fn;
};

// create a new list
struct list *list_new(void);

// removed linked list nodes but does not free their content
void list_clear(struct list *list);

// insert a new item at the begin of the list.
void *list_insert(struct list *list, void *data);

// append a new item at the end of the list.
void *list_append(struct list *list, void *data);

// returns true if entry was removed, false otherwise
bool list_remove(struct list *list, void *data);

// returns true if the data exists in the list
bool list_exists(struct list *list, void *data);

#endif