diff options
Diffstat (limited to 'collections/vector/vector.c')
-rw-r--r-- | collections/vector/vector.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index b3751dd..8aaffb6 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -144,3 +144,23 @@ vec *root; } fprintf(stderr, "\n"); } + +vec* vec_cp(root) +vec *root; +{ + vec *copy; + + if (!root) + return NULL; + + copy = vec_with_capacity(root->limit); + + copy->base = memcpy(copy->base, root->base, + vec_size(root) * sizeof(void*)); + assert(copy->base); + + copy->end = root->end; + copy->limit = root->limit; + + return copy; +} |