Provides global memory allocation routines using instance-based allocators. More...
#include "Types.h"

Go to the source code of this file.
Namespaces | |
| namespace | kNet |
Enumerations | |
| enum | { kNet::AFAllocLow = 0x1, kNet::AFAllocHigh = 0x2 } |
Functions | |
| template<typename Object , typename Allocator > | |
| Object * | kNet::New (Allocator *allocator, size_t alignment, const char *nameTag=0, AllocFlags flags=AFAllocLow) |
| The global memory/object allocation function. | |
| template<typename Object , typename Allocator > | |
| Object * | kNet::NewArray (size_t numObjects, Allocator *allocator, size_t alignment, const char *nameTag=0, AllocFlags flags=AFAllocLow) |
| Allocates an array of objects. | |
| template<typename Object , typename Allocator > | |
| void | kNet::Delete (Object *ptr, Allocator *allocator) |
| Object deletion function. | |
| template<typename Object , typename Allocator > | |
| void | kNet::DeleteArray (Object *ptr, Allocator *allocator) |
| Array of objects deletion function. | |
Provides global memory allocation routines using instance-based allocators.
All allocators in the system are instance-based (in contrast to class-based). This implies a few things: 1. Because all memory allocation is performed through allocators, you need to create an allocator instance to be able to allocate memory. 2. Each container will have a pointer to the allocator instance it's using. 3. There are no general global (static/class-based/compile time -based) memory allocators.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1850.pdf for loosely related discussion (mainly class-based vs instance-based allocator system). An allocator must support the following concept:
class Allocator { public: static void *Alloc(Allocator *instance, size_t size, size_t alignment, const char *nameTag = 0, AllocFlags flags = AFAllocLow); static void Free(Allocator *instance, void *ptr); static size_t Size(Allocator *instance, void *ptr); };
The reason that the member functions are static, but still take in as the first parameter an instance of the Allocator is that this allows both class-based and instance-based allocators to be created using the same interface.
1.7.1