diff options
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r-- | collections/vector/vector.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 391b5a6..f14c302 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -250,6 +250,20 @@ int size; root->end = size; } +void vec_reserve(root, n) +vec *root; +int n; +{ + int i; + + if (!root || n + root->end <= root->limit) + return; + + for (i = root->limit; i < root->end + n; i*=2); + + root->base = reallocarray(root->base, i, sizeof(void*)); +} + void vec_clear(root) vec *root; { |