diff options
author | schu <schu-github@schulog.org> | 2011-05-11 16:00:38 +0400 |
---|---|---|
committer | schu <schu-github@schulog.org> | 2011-05-11 16:00:53 +0400 |
commit | 86f5fa7810c5675d5c789450c9c140330432bbbb (patch) | |
tree | 5516e7b52e3470554c3fa8f7ee0bcc3ddd0b41e4 /src/vector.c | |
parent | d6de92b6fe5d04111c3e9cd4a0c269c840ce59b6 (diff) |
Move vector.c to the new error handling
Remove "redundant" check for v->_cmp in wrapper function
git_vector_bsearch().
Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'src/vector.c')
-rw-r--r-- | src/vector.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/vector.c b/src/vector.c index d0b0c5c56..1ddc26e3e 100644 --- a/src/vector.c +++ b/src/vector.c @@ -106,7 +106,7 @@ int git_vector_bsearch2(git_vector *v, git_vector_cmp key_lookup, const void *ke /* need comparison function to sort the vector */ if (v->_cmp == NULL) - return GIT_ENOTFOUND; + return git__throw(GIT_ENOTFOUND, "Can't sort vector. No comparison function set"); git_vector_sort(v); @@ -114,7 +114,7 @@ int git_vector_bsearch2(git_vector *v, git_vector_cmp key_lookup, const void *ke if (find != NULL) return (int)(find - v->contents); - return GIT_ENOTFOUND; + return git__throw(GIT_ENOTFOUND, "Can't find element"); } int git_vector_search2(git_vector *v, git_vector_cmp key_lookup, const void *key) @@ -128,7 +128,7 @@ int git_vector_search2(git_vector *v, git_vector_cmp key_lookup, const void *key return i; } - return GIT_ENOTFOUND; + return git__throw(GIT_ENOTFOUND, "Can't find element"); } static int strict_comparison(const void *a, const void *b) @@ -143,9 +143,6 @@ int git_vector_search(git_vector *v, const void *entry) int git_vector_bsearch(git_vector *v, const void *key) { - if (v->_cmp == NULL) - return GIT_ENOTFOUND; - return git_vector_bsearch2(v, v->_cmp, key); } @@ -156,7 +153,7 @@ int git_vector_remove(git_vector *v, unsigned int idx) assert(v); if (idx >= v->length || v->length == 0) - return GIT_ENOTFOUND; + return git__throw(GIT_ENOTFOUND, "Can't remove element. Index out of bounds"); for (i = idx; i < v->length - 1; ++i) v->contents[i] = v->contents[i + 1]; |