Blender V4.3
util_aligned_malloc_test.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "testing/testing.h"
6
8
9#define CHECK_ALIGNMENT(ptr, align) EXPECT_EQ((size_t)ptr % align, 0)
10
12
13TEST(util_aligned_malloc, aligned_malloc_16)
14{
15 int *mem = (int *)util_aligned_malloc(sizeof(int), 16);
16 CHECK_ALIGNMENT(mem, 16);
18}
19
20/* On Apple we currently only support 16 bytes alignment. */
21#ifndef __APPLE__
22TEST(util_aligned_malloc, aligned_malloc_32)
23{
24 int *mem = (int *)util_aligned_malloc(sizeof(int), 32);
25 CHECK_ALIGNMENT(mem, 32);
27}
28#endif /* __APPLE__ */
29
void util_aligned_free(void *ptr)
CCL_NAMESPACE_BEGIN void * util_aligned_malloc(size_t size, int alignment)
#define CCL_NAMESPACE_END
#define CHECK_ALIGNMENT(ptr, align)
CCL_NAMESPACE_BEGIN TEST(util_aligned_malloc, aligned_malloc_16)