From ded2768def4108e78eeb9f9bbefe5ea8dfa3a170 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 31 Dec 2022 02:31:24 +0100 Subject: Make vector lengths “public” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/gevector.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'examples') 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); } -- cgit v1.2.3