aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/gpr/alloc_test.cc
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2018-01-22 12:51:03 -0800
committerGravatar Mark D. Roth <roth@google.com>2018-01-22 12:51:03 -0800
commit62569dd9785e59a6b87a5002d09aeec1c39f541b (patch)
treeb7e0fd0f075b891af60f1c6736a04ed12f77bf16 /test/core/gpr/alloc_test.cc
parenta9fc084ec1be4ab8f2071227d9affb77f713e0db (diff)
Fix arena to return aligned memory.
Diffstat (limited to 'test/core/gpr/alloc_test.cc')
-rw-r--r--test/core/gpr/alloc_test.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/core/gpr/alloc_test.cc b/test/core/gpr/alloc_test.cc
index 6074c6e6e7..bf4471c36f 100644
--- a/test/core/gpr/alloc_test.cc
+++ b/test/core/gpr/alloc_test.cc
@@ -16,8 +16,11 @@
*
*/
+#include <string.h>
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+
#include "test/core/util/test_config.h"
static void* fake_malloc(size_t size) { return (void*)size; }
@@ -48,8 +51,19 @@ static void test_custom_allocs() {
gpr_free(i);
}
+static void test_malloc_aligned() {
+ for (size_t size = 1; size <= 256; ++size) {
+ void* ptr = gpr_malloc_aligned(size, 16);
+ GPR_ASSERT(ptr != nullptr);
+ GPR_ASSERT(((intptr_t)ptr & 0xf) == 0);
+ memset(ptr, 0, size);
+ gpr_free_aligned(ptr);
+ }
+}
+
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_custom_allocs();
+ test_malloc_aligned();
return 0;
}