summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-12 12:19:37 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-13 09:27:33 -0500
commitf1453c59b2afb9dab43281bfe9f1ba34cf6e0d02 (patch)
treecb189e211547042080f35227b7e4d3f9b0c8ac2a /src/array.h
parent650e45f69124bd8b53ecefddeb214a82538ab2c1 (diff)
downloadlibgit2-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/array.h')
-rw-r--r--src/array.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/array.h b/src/array.h
index 7c4dbdbc1..7cd9b7153 100644
--- a/src/array.h
+++ b/src/array.h
@@ -51,10 +51,9 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
if (a->size < 8) {
new_size = 8;
} else {
- if (GIT_ALLOC_OVERFLOW_MULTIPLY(a->size, 3 / 2))
+ if (GIT_MULTIPLY_SIZET_OVERFLOW(&new_size, a->size, 3))
goto on_oom;
-
- new_size = a->size * 3 / 2;
+ new_size /= 2;
}
if ((new_array = git__reallocarray(a->ptr, new_size, item_size)) == NULL)