-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl_list.h
33 lines (25 loc) · 850 Bytes
/
dl_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
#ifndef __DL_LIST
#define __DL_LIST
#include "dl_base.h"
typedef struct _dl_list_part dl_list_part;
/*
* linked list
* every part is an array, list->nalloc = 1 == normal linked list
*/
struct _dl_list_part {
void *elts;
int nelts; // the number of elements in this part
dl_list_part *next;
};
struct _dl_list{
dl_list_part *last; // current part in use, the current part == the last part
dl_list_part part;
size_t size; // element size
int nalloc; // every part can contain nalloc element
int nelts; // total elements
dl_pool *pool;
};
dl_list *dl_list_create(dl_pool *pool, int n, size_t size);
int dl_list_init(dl_list *list, dl_pool *pool, int n, size_t size);
void *dl_list_push(dl_list *l);
#endif