4 #ifndef __UTIL_STACK_ALLOCATOR_H__
5 #define __UTIL_STACK_ALLOCATOR_H__
13 template<
int SIZE,
typename T>
class ccl_try_align(16) StackAllocator
17 typedef ptrdiff_t difference_type;
19 typedef const T *const_pointer;
21 typedef const T &const_reference;
26 StackAllocator() : pointer_(0), use_stack_(
true)
30 StackAllocator(
const StackAllocator &) : pointer_(0), use_stack_(
true)
35 StackAllocator(
const StackAllocator<SIZE, U> &) : pointer_(0), use_stack_(
false)
41 T *allocate(
size_t n,
const void *hint = 0)
47 if (pointer_ + n >=
SIZE || use_stack_ ==
false) {
48 size_t size = n *
sizeof(
T);
51 #ifdef WITH_BLENDER_GUARDEDALLOC
54 mem = (
T *)malloc(
size);
57 throw std::bad_alloc();
66 void deallocate(
T * p,
size_t n)
73 #ifdef WITH_BLENDER_GUARDEDALLOC
85 T *address(
T &
x)
const
90 const T *address(
const T &
x)
const
97 void construct(
T * p,
const T &val)
111 size_t max_size()
const
118 template<
class U>
struct rebind {
119 typedef StackAllocator<SIZE, U> other;
124 template<
class U>
inline StackAllocator &
operator=(
const StackAllocator<SIZE, U> &)
129 StackAllocator<SIZE, T> &
operator=(
const StackAllocator &)
134 inline bool operator==(StackAllocator
const & )
const
139 inline bool operator!=(StackAllocator
const &other)
const
void BLI_kdtree_nd_() free(KDTree *tree)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
#define CCL_NAMESPACE_END
SyclQueue void void size_t num_bytes void
void util_guarded_mem_free(size_t n)
void util_guarded_mem_alloc(size_t n)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
bool operator==(const AttributeIDRef &a, const AttributeIDRef &b)
constexpr bool operator!=(StringRef a, StringRef b)
CCL_NAMESPACE_BEGIN class ccl_try_align(16) StackAllocator