Derive-C
Loading...
Searching...
No Matches
circular.c File Reference

Go to the source code of this file.

Macros

#define CAPACITY   300000
#define NAME   bump_alloc
#define ITEM   int
#define ALLOC   bump_alloc
#define NAME   int_queue

Functions

void basic_example ()
int main ()

Macro Definition Documentation

◆ ALLOC

#define ALLOC   bump_alloc

Definition at line 9 of file circular.c.

◆ CAPACITY

#define CAPACITY   300000

Definition at line 4 of file circular.c.

◆ ITEM

#define ITEM   int

Definition at line 8 of file circular.c.

◆ NAME [1/2]

#define NAME   int_queue

Definition at line 5 of file circular.c.

◆ NAME [2/2]

#define NAME   bump_alloc

Definition at line 5 of file circular.c.

Function Documentation

◆ basic_example()

void basic_example ( )

Definition at line 13 of file circular.c.

13 {
14 bump_alloc_buffer buffer = {};
15 bump_alloc alloc = bump_alloc_new(&buffer);
16
17 int_queue q = int_queue_new_with_capacity_for(8, &alloc);
18
19 int_queue_push_back(&q, 1);
20 int_queue_push_back(&q, 2);
21 int_queue_push_back(&q, 3);
22
23 DC_ASSERT(int_queue_size(&q) == 3);
24
25 int_queue_debug(&q, dc_debug_fmt_new(), stdout);
26
27 DC_ASSERT(int_queue_pop_front(&q) == 1);
28
29 DC_ASSERT(int_queue_pop_back(&q) == 3);
30
31 int_queue_debug(&q, dc_debug_fmt_new(), stdout);
32
33 int_queue_delete(&q);
34}
char buffer[CAPACITY]
Definition template.h:34
static dc_debug_fmt dc_debug_fmt_new()
Definition fmt.h:14
#define DC_ASSERT(expr,...)
Definition panic.h:36

◆ main()

int main ( )

Definition at line 36 of file circular.c.

36{ basic_example(); }
void basic_example()
Definition circular.c:13