Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-11-02 21:00:28 +0400
committerVicent Martí <vicent@github.com>2012-11-02 21:00:28 +0400
commit1362a983165abb5e85e66c2b0474157ba697966a (patch)
tree2dcd99e991224a26eb860d36151405219ff202bd /src/vector.c
parent473a7a1e70d05ec125309304d56f060c3e3ad40e (diff)
parentdb106d01f093b3e61170e3738d6651a2866cb76e (diff)
Merge pull request #1014 from arrbee/diff-rename-detection
Initial implementation of diff rename detection
Diffstat (limited to 'src/vector.c')
-rw-r--r--src/vector.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vector.c b/src/vector.c
index d9c4c9900..4763792f5 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -255,3 +255,33 @@ void git_vector_swap(git_vector *a, git_vector *b)
memcpy(a, b, sizeof(t));
memcpy(b, &t, sizeof(t));
}
+
+int git_vector_resize_to(git_vector *v, size_t new_length)
+{
+ if (new_length <= v->length)
+ return 0;
+
+ while (new_length >= v->_alloc_size)
+ if (resize_vector(v) < 0)
+ return -1;
+
+ memset(&v->contents[v->length], 0,
+ sizeof(void *) * (new_length - v->length));
+
+ v->length = new_length;
+
+ return 0;
+}
+
+int git_vector_set(void **old, git_vector *v, size_t position, void *value)
+{
+ if (git_vector_resize_to(v, position + 1) < 0)
+ return -1;
+
+ if (old != NULL)
+ *old = v->contents[position];
+
+ v->contents[position] = value;
+
+ return 0;
+}