17 #ifndef __UTIL_STACK_ALLOCATOR_H__
18 #define __UTIL_STACK_ALLOCATOR_H__
26 template<
int SIZE,
typename T>
class ccl_try_align(16) StackAllocator
30 typedef ptrdiff_t difference_type;
32 typedef const T *const_pointer;
34 typedef const T &const_reference;
39 StackAllocator() : pointer_(0), use_stack_(
true)
43 StackAllocator(
const StackAllocator &) : pointer_(0), use_stack_(
true)
48 StackAllocator(
const StackAllocator<SIZE, U> &) : pointer_(0), use_stack_(
false)
54 T *allocate(
size_t n,
const void *hint = 0)
60 if (pointer_ + n >=
SIZE || use_stack_ ==
false) {
61 size_t size = n *
sizeof(
T);
64 #ifdef WITH_BLENDER_GUARDEDALLOC
67 mem = (
T *)malloc(
size);
70 throw std::bad_alloc();
79 void deallocate(
T * p,
size_t n)
86 #ifdef WITH_BLENDER_GUARDEDALLOC
98 T *address(
T &
x)
const
103 const T *address(
const T &
x)
const
110 void construct(
T * p,
const T &val)
124 size_t max_size()
const
131 template<
class U>
struct rebind {
132 typedef StackAllocator<SIZE, U> other;
137 template<
class U>
inline StackAllocator &
operator=(
const StackAllocator<SIZE, U> &)
142 StackAllocator<SIZE, T> &
operator=(
const StackAllocator &)
147 inline bool operator==(StackAllocator
const & )
const
152 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)
bool operator==(const GeometrySet &UNUSED(a), const GeometrySet &UNUSED(b))
#define CCL_NAMESPACE_END
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
constexpr bool operator!=(StringRef a, StringRef b)
void util_guarded_mem_free(size_t n)
void util_guarded_mem_alloc(size_t n)
CCL_NAMESPACE_BEGIN class ccl_try_align(16) StackAllocator