commit f17fb0c063247e2325e95f7137769e6b38876c42
parent 7520b04430cfbbb91fa1a3e7bf94995d18655caf
Author: Louis Burda <quent.burda@gmail.com>
Date: Wed, 30 Mar 2022 02:22:47 +0200
Added VEC_ITER macro for for-loops
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/vec.h b/include/vec.h
@@ -1,6 +1,9 @@
#include <stdbool.h>
#include <stdlib.h>
+#define VEC_ITER(vec, var) \
+ var = NULL; vec_iter(vec, &var);
+
#define VEC_PUSH(vec, type, val) \
do { \
type tmp = (val); \
@@ -46,5 +49,5 @@ void vec_set(struct vec *vec, size_t index, const void *data);
void vec_setbuf(struct vec *vec, void *buf);
void *vec_popbuf(struct vec *vec);
-int vec_empty(struct vec *vec);
+bool vec_empty(struct vec *vec);
int vec_len(struct vec *vec);
diff --git a/src/vec.c b/src/vec.c
@@ -215,7 +215,7 @@ vec_popbuf(struct vec *vec)
return data;
}
-int
+bool
vec_empty(struct vec *vec)
{
ASSERT(vec != NULL);