MCPcopy Create free account
hub / github.com/blender/cycles / util_aligned_malloc

Function util_aligned_malloc

src/util/aligned_malloc.cpp:33–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#endif
32
33CCL_NAMESPACE_BEGIN
34
35void *util_aligned_malloc(const size_t size, const int alignment)
36{
37 void *mem = nullptr;
38#ifdef WITH_BLENDER_GUARDEDALLOC
39 mem = MEM_new_uninitialized_aligned(size, alignment, "Cycles Aligned Alloc");
40#elif defined(_WIN32)
41 mem = _aligned_malloc(size, alignment);
42#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
43 if (posix_memalign(&mem, alignment, size)) {
44 /* Non-zero means allocation error
45 * either no allocation or bad alignment value. */
46 mem = nullptr;
47 }
48#else /* This is for Linux. */
49 mem = memalign(alignment, size);
50#endif
51 if (mem) {
52 util_guarded_mem_alloc(size);
53 }
54 return mem;
55}
56
57void util_aligned_free(void *ptr, const size_t size)
58{

Callers 5

TESTFunction · 0.85
host_allocMethod · 0.85
mem_allocMethod · 0.85
array.hFile · 0.85
util_aligned_newFunction · 0.85

Calls 1

util_guarded_mem_allocFunction · 0.85

Tested by 1

TESTFunction · 0.68