summaryrefslogtreecommitdiff
path: root/src/vector.h
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-02-28 16:14:47 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-03-02 15:49:29 -0800
commit74fa4bfae37e9d7c9e35550c881b114d7a83c4fa (patch)
tree98184643a8c42b1402e4b33f835eac424fe88768 /src/vector.h
parent760db29c456ef2029a81d577d95a3fafb37ce5c6 (diff)
downloadlibgit2-74fa4bfae37e9d7c9e35550c881b114d7a83c4fa.tar.gz
Update diff to use iterators
This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options.
Diffstat (limited to 'src/vector.h')
-rw-r--r--src/vector.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h
index 44635ae14..180edbf7c 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -24,6 +24,7 @@ typedef struct git_vector {
int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp);
void git_vector_free(git_vector *v);
void git_vector_clear(git_vector *v);
+void git_vector_swap(git_vector *a, git_vector *b);
int git_vector_search(git_vector *v, const void *entry);
int git_vector_search2(git_vector *v, git_vector_cmp cmp, const void *key);
@@ -38,6 +39,11 @@ GIT_INLINE(void *) git_vector_get(git_vector *v, unsigned int position)
return (position < v->length) ? v->contents[position] : NULL;
}
+GIT_INLINE(const void *) git_vector_get_const(const git_vector *v, unsigned int position)
+{
+ return (position < v->length) ? v->contents[position] : NULL;
+}
+
GIT_INLINE(void *) git_vector_last(git_vector *v)
{
return (v->length > 0) ? git_vector_get(v, v->length - 1) : NULL;