diff options
Diffstat (limited to 'src/vec.h')
-rw-r--r-- | src/vec.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -73,6 +73,7 @@ static inline void VEC(append)(struct VEC_STRUCT *v, VEC_TYPE n) if (v->n >= v->s) { v->s *= 2; v->buf = realloc(v->buf, v->s * sizeof(VEC_TYPE)); + assert(v->buf); } v->buf[v->n - 1] = n; @@ -99,6 +100,9 @@ static inline void VEC(reserve)(struct VEC_STRUCT *v, size_t n) return; v->n = n; + if (v->s >= v->n) + return; + while (v->s < v->n) v->s *= 2; |