Support for jemalloc to replace dlmalloc.
To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.
Update the pthread_create_key tests since jemalloc uses a few keys.
Add a new test to verify memalign works as expected.
Bug: 981363
Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 259853d..12a5ffa 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -46,7 +46,7 @@
for (size_t i = 0; i <= 12; i++) {
for (size_t alignment = 1 << i; alignment < (1U << (i+1)); alignment++) {
char *ptr = (char*)memalign(alignment, 100);
- ASSERT_TRUE(ptr != NULL);
+ ASSERT_TRUE(ptr != NULL) << alignment;
ASSERT_LE(100U, malloc_usable_size(ptr));
ASSERT_EQ(0, (intptr_t)ptr % (1 << i));
@@ -233,3 +233,18 @@
free(ptr);
}
+
+TEST(malloc, posix_memalign_non_power2) {
+ void* ptr;
+
+ ASSERT_EQ(EINVAL, posix_memalign(&ptr, 17, 1024));
+}
+
+TEST(malloc, memalign_non_power2) {
+ void* ptr;
+ for (size_t align = 0; align <= 256; align++) {
+ ptr = memalign(align, 1024);
+ ASSERT_TRUE(ptr != NULL) << "Failed at align " << align;
+ free(ptr);
+ }
+}