summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-12-31 01:01:23 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-12-31 01:01:23 +0100
commit09925a143f29c390e0c539006b38bdca4955643a (patch)
treeb541bc700b299001574c9de69d58e6d5ba100826 /examples
parent54b10aa8b1951581291ef0bf0fef954860c04191 (diff)
Update gevector example
Diffstat (limited to 'examples')
-rw-r--r--examples/gevector.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/gevector.c b/examples/gevector.c
index 15adbad..df6212e 100644
--- a/examples/gevector.c
+++ b/examples/gevector.c
@@ -3,23 +3,25 @@
#include <gevector.h>
-GEVECTOR_API(int, ivec)
-GEVECTOR_IMPL(int, ivec)
+GEVECTOR_DEF(int, ivec)
int
main(void)
{
- struct ivec *vec = malloc(sizeof(struct ivec));
+ ivec_t *vec = malloc(sizeof(ivec_t));
ivec_new(vec, 2, 0);
- ivec_append(vec, 42);
- ivec_append(vec, 69);
- ivec_append(vec, 420);
+ ivec_push(vec, 42);
+ ivec_push(vec, 69);
+ ivec_push(vec, 420);
ivec_insert(vec, 1337, 2);
- for (size_t i = 0; i < vec->size; i++)
- printf("%d\n", vec->items[i]);
+ GEVECTOR_FOREACH(int, num, *vec)
+ printf("%d\n", num);
+
+ GEVECTOR_ENUMERATE(int, i, num, *vec)
+ printf("vec->data[%zu] == %d\n", i, num);
- free(vec->items);
+ free(vec->data);
free(vec);
}