diff options
Diffstat (limited to 'src/vec.h')
-rw-r--r-- | src/vec.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -92,4 +92,14 @@ static inline void vec_sort(struct vec *v, vec_comp_t comp) qsort(v->buf, v->n, v->ns, (__compar_fn_t)comp); } +static inline void vec_reserve(struct vec *v, size_t n) +{ + if (v->n >= n) + return; + + v->n = n; + v->s = n; + v->buf = realloc(v->buf, v->s * v->ns); +} + #endif /* VEC_H */ |