diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-02-23 03:15:35 +0400 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-23 03:15:35 +0400 |
commit | 0534641dfec001794ae9a83cfd1cfc7acaef97b7 (patch) | |
tree | d17e72af0ae9a9435aef29cc388d50a67a3cc0b0 /src/vector.c | |
parent | da337c806468d2d8a27dfa9ee5e75e476f5ad546 (diff) |
Fix iterators based on pull request feedback
This update addresses all of the feedback in pull request #570.
The biggest change was to create actual linked list stacks for
storing the tree and workdir iterator state. This cleaned up
the code a ton. Additionally, all of the static functions had
their 'git_' prefix removed, and a lot of other unnecessary
changes were removed from the original patch.
Diffstat (limited to 'src/vector.c')
-rw-r--r-- | src/vector.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/src/vector.c b/src/vector.c index 49909bbad..e109704ab 100644 --- a/src/vector.c +++ b/src/vector.c @@ -25,24 +25,6 @@ static int resize_vector(git_vector *v) return GIT_SUCCESS; } -int git_vector_alloc( - git_vector **vptr, unsigned int initial_size, git_vector_cmp cmp) -{ - int error; - git_vector *v = git__malloc(sizeof(git_vector)); - if (!v) { - *vptr = NULL; - return GIT_ENOMEM; - } - - if ((error = git_vector_init(v, initial_size, cmp)) < GIT_SUCCESS) { - git__free(v); - v = NULL; - } - *vptr = v; - return error; -} - void git_vector_free(git_vector *v) { assert(v); @@ -205,19 +187,10 @@ int git_vector_remove(git_vector *v, unsigned int idx) return GIT_SUCCESS; } -int git_vector_pop(git_vector *v, void **element) +void git_vector_pop(git_vector *v) { - assert(v); - - if (v->length == 0) - return git__throw(GIT_ENOTFOUND, "Can't remove element from empty list"); - - if (element != NULL) - *element = v->contents[v->length - 1]; - - v->length--; - - return GIT_SUCCESS; + if (v->length > 0) + v->length--; } void git_vector_uniq(git_vector *v) |