It sets the size back to 0 and deallocates the underlying vector.
Note that if the vector elements are allocated (eg. strings) this does
not free them, so the correct way to fully deallocate a vector of
non-const strings might be:
string_vector_iter (&strings, (void *) free);
string_vector_reset (&strings);
---
common/utils/vector.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/common/utils/vector.h b/common/utils/vector.h
index 15733e54..6468fd9b 100644
--- a/common/utils/vector.h
+++ b/common/utils/vector.h
@@ -126,6 +126,15 @@
v->size--; \
} \
\
+ /* Remove all elements and deallocate the vector. */ \
+ static inline void \
+ name##_reset (name *v) \
+ { \
+ free (v->ptr); \
+ v->ptr = NULL; \
+ v->size = v->alloc = 0; \
+ } \
+ \
/* Iterate over the vector, calling f() on each element. */ \
static inline void \
name##_iter (name *v, void (*f) (type elem)) \
--
2.27.0