11#ifdef WITH_BLENDER_GUARDEDALLOC
35 T *
allocate(
const size_t n,
const void *hint =
nullptr)
38 size_t size = n *
sizeof(
T);
44#ifdef WITH_BLENDER_GUARDEDALLOC
52 mem = (
T *)malloc(
size);
55 throw std::bad_alloc();
64#ifdef WITH_BLENDER_GUARDEDALLOC
65 MEM_freeN(
const_cast<void *
>(
static_cast<const void *
>(p)));
126 template<>
struct rebind<std::_Container_proxy> {
127 typedef std::allocator<std::_Container_proxy>
other;
130 operator std::allocator<std::_Container_proxy>()
const
132 return std::allocator<std::_Container_proxy>();
149#define MEM_GUARDED_CALL(progress, func, ...) \
152 (func)(__VA_ARGS__); \
154 catch (std::bad_alloc &) { \
155 LOG_ERROR << "Out of memory"; \
157 (progress)->set_error("Out of memory"); \
void BLI_kdtree_nd_ free(KDTree *tree)
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
bool operator!=(const GuardedAllocator &other) const
const T & const_reference
GuardedAllocator< T > & operator=(const GuardedAllocator &)=default
bool operator==(const GuardedAllocator &) const
T * allocate(const size_t n, const void *hint=nullptr)
GuardedAllocator & operator=(const GuardedAllocator< U > &)
GuardedAllocator(const GuardedAllocator< U > &)
GuardedAllocator()=default
const T * address(const T &x) const
ptrdiff_t difference_type
GuardedAllocator(const GuardedAllocator &)=default
void deallocate(T *p, const size_t n)
#define CCL_NAMESPACE_END
size_t util_guarded_get_mem_used()
size_t util_guarded_get_mem_peak()
CCL_NAMESPACE_BEGIN void util_guarded_mem_alloc(const size_t n)
void util_guarded_mem_free(const size_t n)
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void MEM_freeN(void *vmemh)
GuardedAllocator< U > other