5#ifndef __UTIL_STACK_ALLOCATOR_H__
6#define __UTIL_STACK_ALLOCATOR_H__
14template<
int SIZE,
typename T>
class ccl_try_align(16) StackAllocator
18 typedef ptrdiff_t difference_type;
20 typedef const T *const_pointer;
22 typedef const T &const_reference;
27 StackAllocator() : pointer_(0), use_stack_(
true) {}
29 StackAllocator(
const StackAllocator &) : pointer_(0), use_stack_(
true) {}
32 StackAllocator(
const StackAllocator<SIZE, U> &) : pointer_(0), use_stack_(
false)
38 T *allocate(
size_t n,
const void *hint = 0)
44 if (pointer_ + n >=
SIZE || use_stack_ ==
false) {
45 size_t size = n *
sizeof(
T);
48#ifdef WITH_BLENDER_GUARDEDALLOC
51 mem = (
T *)malloc(
size);
54 throw std::bad_alloc();
58 T *mem = &data_[pointer_];
63 void deallocate(
T * p,
size_t n)
68 if (p < data_ || p >= data_ +
SIZE) {
70#ifdef WITH_BLENDER_GUARDEDALLOC
82 T *address(
T &
x)
const
87 const T *address(
const T &
x)
const
94 void construct(
T * p,
const T &val)
108 size_t max_size()
const
115 template<
class U>
struct rebind {
116 typedef StackAllocator<SIZE, U> other;
121 template<
class U>
inline StackAllocator &
operator=(
const StackAllocator<SIZE, U> &)
126 StackAllocator<SIZE, T> &
operator=(
const StackAllocator &)
131 inline bool operator==(StackAllocator
const & )
const
136 inline bool operator!=(StackAllocator
const &other)
const
void BLI_kdtree_nd_ free(KDTree *tree)
bool operator==(const AssetWeakReference &a, const AssetWeakReference &b)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
#define CCL_NAMESPACE_END
#define ccl_try_align(...)
void util_guarded_mem_free(size_t n)
void util_guarded_mem_alloc(size_t n)
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline bool operator!=(const float2 a, const float2 b)