Blender V4.5
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
14/* Allocate block of size bytes at least aligned to a given value. */
15void *util_aligned_malloc(const size_t size, const int alignment);
16
17/* Free memory allocated by util_aligned_malloc. */
18void util_aligned_free(void *ptr, const size_t size);
19
20/* Aligned new operator. */
21template<typename T, typename... Args> T *util_aligned_new(Args... args)
22{
23 void *mem = util_aligned_malloc(sizeof(T), alignof(T));
24 return new (mem) T(args...);
25}
26
27template<typename T> void util_aligned_delete(T *t)
28{
29 if (t) {
30 t->~T();
31 util_aligned_free(t, sizeof(T));
32 }
33}
34
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:4226