library of assembled shared sources

http://lass.cocamware.com

lass::util::AllocatorSized< VariableAllocator > Class Template Reference
[Allocator]

#include <allocator.h>


Public Member Functions

void * allocate (size_t size)
void deallocate (void *mem, size_t size)
void deallocate (void *mem)


Detailed Description

template<typename VariableAllocator = AllocatorMalloc>
class lass::util::AllocatorSized< VariableAllocator >

AllocatorSized adds sizeof(size_t) bytes in front of the returned pointer to store the requested block size. Because of that, you can use the simpler form void deallocate(void* mem) to deallocate the memory.

Warning:
the fact that this allocator supports void deallocate(void* mem) does NOT mean it implements the FixedAllocator concept, not even partially. So when you use AllocatorSized as a base for an allocator that implements both the VariableAllocator as FixedAllocator concept depending on the base allocator (such as AllocatorStats), the result will be a VariableAllocator. You cannot generally assume you will be able to use void deallocate(void* mem) on the resulting allocator as well. Particularly for AllocatorStats, it is know that this will cause undefined behaviour. However, using AllocatorStats as base AllocatorSized will achieve the desired effect perfectly well, and will cause no problem (= using AllocatorSized on top-level)
it is advised to use AllocatorSized as a top-level allocator. Using AllocatorSized as a base allocator for others can cause undefined behaviour. A notable exception is AllocatorSingleton, it is safe to use that one on top of AllocatorSized.

Definition at line 1090 of file allocator.h.


Member Function Documentation

template<typename VariableAllocator = AllocatorMalloc>
void* lass::util::AllocatorSized< VariableAllocator >::allocate ( size_t  size  )  [inline]

Definition at line 1093 of file allocator.h.

template<typename VariableAllocator = AllocatorMalloc>
void lass::util::AllocatorSized< VariableAllocator >::deallocate ( void *  mem,
size_t  size 
) [inline]

Definition at line 1099 of file allocator.h.

References LASS_ASSERT.

template<typename VariableAllocator = AllocatorMalloc>
void lass::util::AllocatorSized< VariableAllocator >::deallocate ( void *  mem  )  [inline]

Definition at line 1105 of file allocator.h.


The documentation for this class was generated from the following file:

Generated on Mon Nov 10 14:22:16 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo