-
Notifications
You must be signed in to change notification settings - Fork 0
/
clist.h
31 lines (26 loc) · 820 Bytes
/
clist.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
/* clist.h */
#ifndef CLIST_H
#define CLIST_H
#include <stdlib.h>
/* define a structure for circular list elements. */
typedef struct CListElmt_ {
void *data;
struct CListElmt_ *next;
}CListElmt;
/* define a structure for circular lists.*/
typedef struct CList_ {
int size;
int (*match)(const void *key1, const void *key2);
void (*destroy)(void *data);
CListElmt *head;
}CList;
/* Public interface */
void clist_init(CList *list, void (*destroy)(void *date));
void clist_destroy(CList *list);
int clist_ins_next(CList *list, CListElmt *element, const void *data);
int clist_rem_next(CList *list, CListElmt *element, void **data);
#define clist_size(list) ((list)->size)
#define clist_head(list) ((list)->head)
#define clist_data(element) ((element)->data)
#define clist_next(element) ((element)->next)
#endif