forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 9
/
linkedqueue.h
executable file
·47 lines (34 loc) · 1.06 KB
/
linkedqueue.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
#ifndef LINKEDLIST_H_INCLUDED
#define LINKEDLIST_H_INCLUDED
#include "utils.h"
typedef struct _ListHead ListHead;
struct _ListHead{;
ListHead *Next;
};
typedef struct _LinkedQueue LinkedQueue;
struct _LinkedQueue{
/* private */
ListHead *First;
int DataLength;
int (*Compare)(const void *One, const void *Two);
/* public */
int (*Add)(LinkedQueue *l, const void *Data);
void *(*Get)(LinkedQueue *l);
void (*Free)(LinkedQueue *l);
};
int LinkedQueue_Init(LinkedQueue *l,
int DataLength,
int (*CompareFunc)(const void *One, const void *Two)
);
#define LinkedQueue_FreeNode(ptr) do {if ((ptr) != NULL) free(((ListHead *)(ptr)) - 1);} while (0)
/** Iterator Implementation */
typedef struct _LinkedQueueIterator LinkedQueueIterator;
struct _LinkedQueueIterator{
/* private */
ListHead *Current;
LinkedQueue *l;
/* public */
void *(*Next)(LinkedQueueIterator *i);
};
int LinkedQueueIterator_Init(LinkedQueueIterator *i, LinkedQueue *l);
#endif /* LINKEDLIST */