summaryrefslogtreecommitdiff
path: root/src/vector.c
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-05-16 09:57:45 -0700
committerVicent Martí <tanoku@gmail.com>2012-05-16 09:57:45 -0700
commitc261c272af7fa26af36bca71e56b0342631b3eea (patch)
tree4b4e6efe8871844b40c8c4ec82321ada515f594d /src/vector.c
parentb206d74ccaca2bca33e5db85fb6c1e4b8fc54541 (diff)
parent2c8339172878cd935eee0d9eb6db747cebd70a72 (diff)
downloadlibgit2-c261c272af7fa26af36bca71e56b0342631b3eea.tar.gz
Merge pull request #702 from arrbee/fix-status-file
Update git_status_file and add ranged iterators
Diffstat (limited to 'src/vector.c')
-rw-r--r--src/vector.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/vector.c b/src/vector.c
index 304f324f0..6f9aacccf 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -116,8 +116,13 @@ void git_vector_sort(git_vector *v)
v->sorted = 1;
}
-int git_vector_bsearch2(git_vector *v, git_vector_cmp key_lookup, const void *key)
+int git_vector_bsearch3(
+ unsigned int *at_pos,
+ git_vector *v,
+ git_vector_cmp key_lookup,
+ const void *key)
{
+ int rval;
size_t pos;
assert(v && key && key_lookup);
@@ -127,13 +132,16 @@ int git_vector_bsearch2(git_vector *v, git_vector_cmp key_lookup, const void *ke
git_vector_sort(v);
- if (git__bsearch(v->contents, v->length, key, key_lookup, &pos) >= 0)
- return (int)pos;
+ rval = git__bsearch(v->contents, v->length, key, key_lookup, &pos);
- return GIT_ENOTFOUND;
+ if (at_pos != NULL)
+ *at_pos = (unsigned int)pos;
+
+ return (rval >= 0) ? (int)pos : GIT_ENOTFOUND;
}
-int git_vector_search2(git_vector *v, git_vector_cmp key_lookup, const void *key)
+int git_vector_search2(
+ git_vector *v, git_vector_cmp key_lookup, const void *key)
{
unsigned int i;
@@ -157,11 +165,6 @@ int git_vector_search(git_vector *v, const void *entry)
return git_vector_search2(v, v->_cmp ? v->_cmp : strict_comparison, entry);
}
-int git_vector_bsearch(git_vector *v, const void *key)
-{
- return git_vector_bsearch2(v, v->_cmp, key);
-}
-
int git_vector_remove(git_vector *v, unsigned int idx)
{
unsigned int i;