Blender V5.0
cycles/util/aligned_malloc.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include <cstddef>
8
10
11/* Minimum alignment needed by all CPU native data types (SSE, AVX). */
12#define MIN_ALIGNMENT_CPU_DATA_TYPES 16 // NOLINT
13/* NanoVDB needs at least 32 byte alignment. */
14#define MIN_ALIGNMENT_DEVICE_MEMORY 32 // NOLINT
15
16/* Allocate block of size bytes at least aligned to a given value. */
17void *util_aligned_malloc(const size_t size, const int alignment);
18
19/* Free memory allocated by util_aligned_malloc. */
20void util_aligned_free(void *ptr, const size_t size);
21
22/* Aligned new operator. */
23template<typename T, typename... Args> T *util_aligned_new(Args... args)
24{
25 void *mem = util_aligned_malloc(sizeof(T), alignof(T));
26 return new (mem) T(args...);
27}
28
29template<typename T> void util_aligned_delete(T *t)
30{
31 if (t) {
32 t->~T();
33 util_aligned_free(t, sizeof(T));
34 }
35}
36
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
void * util_aligned_malloc(const size_t size, const int alignment)
T * util_aligned_new(Args... args)
void util_aligned_delete(T *t)
void util_aligned_free(void *ptr, const size_t size)
#define CCL_NAMESPACE_END
#define T
PointerRNA * ptr
Definition wm_files.cc:4238