diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 17:32:56 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 19:41:22 -0400 |
commit | 0d09851c392829a6cbbd047f9a374b5c66eb4c98 (patch) | |
tree | 1bc98adad193667f60f5c918a6deaa244a89fbbc /collections/vector/vector.c | |
parent | bc9e78bb7e3fd57a3683e6c8a848b5769d2b21f7 (diff) |
Add push for vector
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 c2668e4..afe99de 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -61,3 +61,17 @@ vec *root; assert(root->base); } +void vec_push(root, item) +vec *root; +void *item; +{ + if (!root) { + return; + } + + if (root->end >= root->limit) { + vec_resize(root); + } + + root->base[root->end++] = item; +} |