diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-01 16:43:07 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-01 16:47:01 -0400 |
commit | bc9e78bb7e3fd57a3683e6c8a848b5769d2b21f7 (patch) | |
tree | 46da2aff2d9631a41a7cc7dfdf46051382a86f3a /collections/vector | |
parent | 65ddeea23e1303d0b2d9656601b90df138d19e6c (diff) |
Add resize function for vector
Diffstat (limited to 'collections/vector')
-rw-r--r-- | collections/vector/vector.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 2c75bc1..c2668e4 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -51,3 +51,13 @@ vec *root; return root->end; } +void vec_resize(root) +vec *root; +{ + if (!root) + return; + + root->base = reallocarray(root->base, root->limit * 2, sizeof(void*)); + assert(root->base); +} + |