template<class Allocator, typename Prefix, typename Sufix = affix_helper::no_affix>
class alb::v_100::affix_allocator< Allocator, Prefix, Sufix >
This allocator enables the possibility to surround allocated memory blocks with guards, ref-counter, mutex or etc. It is used by the alb::allocator_with_stats It automatically places an object of type Prefix before the returned memory location and an object of type Sufix after it. In case that they are of type affix_allocatorHelper::Empty nothing is inserted. Depending on the alignment of the used Allocator, Prefix, memory and Sufix are each aligned. Prefix and Sufix, if used, must be trivially copyable. (This cannot be statically asserted, because this would block the possibility to use this allocator as guard for memory under- or overflow. One should keep in mind, that using a Sufix is not CPU cache friendly!
- Template Parameters
-
Allocator | The allocator that is used as underlying allocator |
Prefix | If defined, then an object of that kind is constructed in front of any returned block |
Sufix | If defined, then an object of that kind is constructed beyond any returned block |
Definition at line 45 of file affix_allocator.hpp.
template<class Allocator, typename Prefix, typename Sufix = affix_helper::no_affix>
Allocates a Block of n bytes. Actually a Block of n + sizeof(Prefix) + sizeof(Sufix) bytes is allocated. Depending of the defines Prefix and Sufix types objects of this gets instantiated before and/or beyond the returned Block. If Zero bytes are allocated then no allocation at all takes places and an empty Block is returned.
- Parameters
-
n | Specifies the number of requested bytes. n or more bytes are returned, depending on the alignment of the underlying Allocator. |
Definition at line 128 of file affix_allocator.hpp.
template<class Allocator, typename Prefix, typename Sufix = affix_helper::no_affix>
template<typename U = Allocator>
The method tries to expand the given block by at least delta bytes insito at the given location. This is only available if the underlaying Allocator implements ::expand().
- Parameters
-
b | The block that should be expanded |
delta | The number of bytes that the given block should be increased |
- Returns
- True, if the operation was successful.
Definition at line 220 of file affix_allocator.hpp.
template<class Allocator, typename Prefix, typename Sufix = affix_helper::no_affix>
template<typename U = Allocator>
If the underlying Allocator defines ::owns() this method is available. It returns true, if the given block is owned by this allocator.
- Parameters
-
b | The Block that should be checked for ownership |
Definition at line 177 of file affix_allocator.hpp.