-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
52 lines (47 loc) · 1.12 KB
/
list.h
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
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __LIST_H
#define __LIST_H
#ifdef THREAD_SAFE
#include <pthread.h>
#endif
/* Define the list item */
struct _list_item {
void *item;
int size;
struct _list_item *prev;
struct _list_item *next;
};
typedef struct _list_item * list_item;
#define LIST_ITEM_SIZE sizeof(struct _list_item)
/* Define the list */
struct _list {
int type; /* Data type in list */
list_item first; /* First item in list */
list_item last; /* Last item in list */
list_item next; /* Next item in list */
#ifdef THREAD_SAFE
pthread_mutex_t mutex;
#endif
};
typedef struct _list * list;
#define LIST_SIZE sizeof(struct _list)
#ifdef __cplusplus
extern "C" {
#endif
/* Define the list functions */
list list_create( void );
int list_destroy( list );
list list_dup( list );
void *list_add( list, void *, int );
int list_add_list( list, list );
int list_delete( list, void * );
void *list_get_next( list );
#define list_next list_get_next
int list_reset( list );
int list_count( list );
int list_is_next( list );
typedef int (*list_compare)(list_item, list_item);
int list_sort( list, list_compare, int);
#ifdef __cplusplus
}
#endif
#endif /* __LIST_H */