blob: 903f64fc2361bd3cb0010cff09ea4e9e318b81a5 (
plain)
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
|
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define NELEM(x) (sizeof(x) / sizeof(x[0]))
typedef int T;
#define START_CAPACITY 8
struct deque {
T ** chunks;
size_t head;
size_t tail;
size_t capacity;
};
void
deque_init(struct deque *d)
{
d->head = 0;
d->tail = 0;
d->capacity = START_CAPACITY;
d->chunks = calloc(d->capacity, sizeof *d->chunks);
}
void
deque_free(struct deque *d)
{
free(d->chunks);
}
int
main(void)
{
struct deque c;
deque_init(&c);
deque_free(&c);
return 0;
}
|