From 220bc631f92890d09d7473eb62e80966faaefc4d Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 1 Mar 2015 13:26:58 -0500 Subject: make jump-dis use a vec as a stack, rather than a hacky queue --- lib/cbit/vec.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/cbit/vec.h') 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)); \ -- cgit v1.2.3