aboutsummaryrefslogtreecommitdiff
path: root/lib/cbit/vec.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cbit/vec.h')
-rw-r--r--lib/cbit/vec.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/cbit/vec.h b/lib/cbit/vec.h
index 87e4c28..2889ac1 100644
--- a/lib/cbit/vec.h
+++ b/lib/cbit/vec.h
@@ -70,6 +70,15 @@ void vec_realloc_internal_as_necessary(struct vec_internal *vi,
*vec_appendp_##name(v) = val; \
} \
UNUSED_STATIC_INLINE \
+ VEC_TY(name) vec_pop_##name(struct vec_##name *v) { \
+ size_t i = v->length - 1; \
+ VEC_TY(name) ret = v->els[i]; \
+ if (i - 1 < v->capacity / 3) \
+ vec_realloc_internal_as_necessary(&v->vi, i - 1, sizeof(v->els[0])); \
+ v->length = i; \
+ return ret; \
+ } \
+ UNUSED_STATIC_INLINE \
void vec_concat_##name(struct vec_##name *v1, const struct vec_##name *v2) { \
size_t l1 = v1->length, l2 = v2->length; \
vec_resize_##name(v1, safe_add(l1, l2)); \