summaryrefslogtreecommitdiff
path: root/examples/gevector.c
blob: e554005319f057d82a7a8bc6b2d878facac34590 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>

#include <gevector.h>

GEVECTOR_API(int, ivec);
GEVECTOR_IMPL(int, ivec);

int
main(void)
{
	struct ivec *vec = malloc(sizeof(struct ivec));
	ivec_new(vec, 2, 0);

	ivec_append(vec, 42);
	ivec_append(vec, 69);
	ivec_append(vec, 420);
	ivec_insert(vec, 1337, 2);

	for (size_t i = 0; i < vec->size; i++)
		printf("%d\n", vec->items[i]);
 
	free(vec->items);
	free(vec);
}