diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2015-02-12 12:19:37 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2015-02-13 09:27:33 -0500 |
| commit | f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02 (patch) | |
| tree | cb189e211547042080f35227b7e4d3f9b0c8ac2a /src/iterator.c | |
| parent | 650e45f69124bd8b53ecefddeb214a82538ab2c1 (diff) | |
| download | libgit2-f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02.tar.gz | |
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it. This means dropping the ability to pass `NULL` as
an out parameter.
As a result, the macros also get updated to reflect this as well.
Diffstat (limited to 'src/iterator.c')
| -rw-r--r-- | src/iterator.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/iterator.c b/src/iterator.c index e90cf30ff..9ddacebd1 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -344,11 +344,8 @@ static int tree_iterator__push_frame(tree_iterator *ti) for (i = head->current; i < head->next; ++i) n_entries += git_tree_entrycount(head->entries[i]->tree); - GITERR_CHECK_ALLOC_MULTIPLY(sizeof(tree_iterator_entry *), n_entries); - alloclen = sizeof(tree_iterator_entry *) * n_entries; - - GITERR_CHECK_ALLOC_ADD(alloclen, sizeof(tree_iterator_frame)); - alloclen += sizeof(tree_iterator_frame); + GITERR_CHECK_ALLOC_MULTIPLY(&alloclen, sizeof(tree_iterator_entry *), n_entries); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, sizeof(tree_iterator_frame)); tf = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(tf); |
