Blender
V3.3
|
#include <algorithm>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "BLI_utildefines.h"
Go to the source code of this file.
Classes | |
class | blender::GuardedAllocator |
class | blender::RawAllocator |
Namespaces | |
blender | |
An Allocator
can allocate and deallocate memory. It is used by containers such as blender::Vector. The allocators defined in this file do not work with standard library containers such as std::vector.
Every allocator has to implement two methods: void *allocate(size_t size, size_t alignment, const char *name); void deallocate(void *ptr);
We don't use the std::allocator interface, because it does more than is really necessary for an allocator and has some other quirks. It mixes the concepts of allocation and construction. It is essentially forced to be a template, even though the allocator should not care about the type. Also see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html#std_allocator. Some of these aspects have been improved in new versions of C++, so we might have to reevaluate the strategy later on.
The allocator interface dictated by this file is very simplistic, but for now that is all we need. More complexity can be added when it seems necessary.
Definition in file BLI_allocator.hh.