summaryrefslogtreecommitdiff
path: root/src/vector.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-12-06 15:04:31 -0800
committerRussell Belfer <rb@github.com>2013-12-11 10:57:49 -0800
commitfcd324c625d8be3f368c924d787e945e5812d8dd (patch)
treeac1e54b2538cdc10ee17dfd7c887c35dd1f572bf /src/vector.c
parentdab89f9b6821b67dd07c8bd4dbb53e25a3e687c7 (diff)
downloadlibgit2-fcd324c625d8be3f368c924d787e945e5812d8dd.tar.gz
Add git_vector_free_all
There are a lot of places that we call git__free on each item in a vector and then call git_vector_free on the vector itself. This just wraps that up into one convenient helper function.
Diffstat (limited to 'src/vector.c')
-rw-r--r--src/vector.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vector.c b/src/vector.c
index 362e7b0c0..9e217b831 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -77,6 +77,20 @@ void git_vector_free(git_vector *v)
v->_alloc_size = 0;
}
+void git_vector_free_all(git_vector *v)
+{
+ size_t i;
+
+ assert(v);
+
+ for (i = 0; i < v->length; ++i) {
+ git__free(v->contents[i]);
+ v->contents[i] = NULL;
+ }
+
+ git_vector_free(v);
+}
+
int git_vector_init(git_vector *v, size_t initial_size, git_vector_cmp cmp)
{
assert(v);