5#ifndef __UTIL_GUARDED_ALLOCATOR_H__
6#define __UTIL_GUARDED_ALLOCATOR_H__
12#ifdef WITH_BLENDER_GUARDEDALLOC
39 size_t size = n *
sizeof(
T);
45#ifdef WITH_BLENDER_GUARDEDALLOC
53 mem = (T *)malloc(size);
56 throw std::bad_alloc();
65#ifdef WITH_BLENDER_GUARDEDALLOC
130 template<>
struct rebind<std::_Container_proxy> {
131 typedef std::allocator<std::_Container_proxy>
other;
134 operator std::allocator<std::_Container_proxy>()
const
136 return std::allocator<std::_Container_proxy>();
153#define MEM_GUARDED_CALL(progress, func, ...) \
156 (func)(__VA_ARGS__); \
158 catch (std::bad_alloc &) { \
159 fprintf(stderr, "Error: run out of memory!\n"); \
161 (progress)->set_error("Out of memory"); \
void BLI_kdtree_nd_ free(KDTree *tree)
Read Guarded memory(de)allocation.
GuardedAllocator< T > & operator=(const GuardedAllocator &)
GuardedAllocator(const GuardedAllocator &)
bool operator==(GuardedAllocator const &) const
const T & const_reference
T * allocate(size_t n, const void *hint=0)
GuardedAllocator & operator=(const GuardedAllocator< U > &)
bool operator!=(GuardedAllocator const &other) const
GuardedAllocator(const GuardedAllocator< U > &)
const T * address(const T &x) const
void deallocate(T *p, size_t n)
ptrdiff_t difference_type
#define CCL_NAMESPACE_END
size_t util_guarded_get_mem_used()
size_t util_guarded_get_mem_peak()
void util_guarded_mem_free(size_t n)
CCL_NAMESPACE_BEGIN 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)
GuardedAllocator< U > other