diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-02 19:20:05 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-04 22:28:36 -0400 |
commit | e4ea23a6c23acdec86e5b5fcd34c653118f6898e (patch) | |
tree | d91e3b1dd813e1ab084369162e6c444b1c70a0f6 /collections/vector/vector.c | |
parent | 98454f841b5ac87d2253c2fae0aba2525853f907 (diff) |
Adds free & clear functions to vectors
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r-- | collections/vector/vector.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 936c0c8..9544917 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -96,3 +96,25 @@ vec *root; return root->base[--root->end]; } + +void vec_free(root) +vec *root; +{ + free(root->base); + root->base = NULL; + + free(root); +} + +void vec_clear(root) +vec *root; +{ + int i; + + for (i = 0; i < root->end; i++) { + free(vec_index(root, i)); + } + + root->end = 0; +} + |