diff options
| author | Christopher Ferris <cferris@google.com> | 2019-03-02 19:11:22 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-03-02 19:11:22 +0000 |
| commit | b8ef55a4f841cb1e790e97776ee51419ec5d9bd1 (patch) | |
| tree | 66d2980a1b04626c7e4fc1437e96194b958ea8f8 /libc/bionic/jemalloc_wrapper.cpp | |
| parent | 0771b752f1b955e7ded6ccbbf825b0ae93439eb5 (diff) | |
| parent | a22f5d5175df5c42ec86d2c2db250edf1f64084c (diff) | |
Merge "Make aligned_alloc match the standard."
Diffstat (limited to 'libc/bionic/jemalloc_wrapper.cpp')
| -rw-r--r-- | libc/bionic/jemalloc_wrapper.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp index ef0d38438..c51324606 100644 --- a/libc/bionic/jemalloc_wrapper.cpp +++ b/libc/bionic/jemalloc_wrapper.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <errno.h> #include <malloc.h> #include <sys/param.h> #include <unistd.h> @@ -48,6 +49,20 @@ void* je_memalign_round_up_boundary(size_t boundary, size_t size) { return je_memalign(boundary, size); } +#ifdef je_aligned_alloc +#undef je_aligned_alloc +#endif + +// The aligned_alloc function requires that size is a multiple of alignment. +// jemalloc doesn't enforce this, so add enforcement here. +void* je_aligned_alloc_wrapper(size_t alignment, size_t size) { + if ((size % alignment) != 0) { + errno = EINVAL; + return nullptr; + } + return je_aligned_alloc(alignment, size); +} + int je_mallopt(int param, int value) { // The only parameter we currently understand is M_DECAY_TIME. if (param == M_DECAY_TIME) { |
