summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-12-31 02:31:24 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-12-31 02:31:24 +0100
commitded2768def4108e78eeb9f9bbefe5ea8dfa3a170 (patch)
tree112bc7527b76609c210724d7d094fedf4776cf8d /examples
parent09925a143f29c390e0c539006b38bdca4955643a (diff)
Make vector lengths “public”
Diffstat (limited to 'examples')
-rw-r--r--examples/gevector.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/examples/gevector.c b/examples/gevector.c
index df6212e..93a1960 100644
--- a/examples/gevector.c
+++ b/examples/gevector.c
@@ -9,19 +9,16 @@ int
main(void)
{
ivec_t *vec = malloc(sizeof(ivec_t));
- ivec_new(vec, 2, 0);
+ ivec_new(vec, 3, 0);
ivec_push(vec, 42);
ivec_push(vec, 69);
ivec_push(vec, 420);
ivec_insert(vec, 1337, 2);
- GEVECTOR_FOREACH(int, num, *vec)
- printf("%d\n", num);
+ for (size_t i = 0; i < vec->len; i++)
+ printf("%d\n", ivec_get(vec, i));
- GEVECTOR_ENUMERATE(int, i, num, *vec)
- printf("vec->data[%zu] == %d\n", i, num);
-
- free(vec->data);
+ ivec_free(vec);
free(vec);
}