Sources Pipelines Documentation

Allocators  
Public Types | Public Member Functions | List of all members
boost::memory::affix_allocator< allocator, prefix, suffix, verify > Class Template Reference

Allocator adding prefix and suffix objects in boundries of allocated block. More...

#include <affix_allocator.hpp>

Public Types

using allocator_type = allocator
 
using prefix_type = prefix
 
using suffix_type = suffix
 

Public Member Functions

memory_block allocate (std::size_t size)
 Allocates a memory_block with configured affixes. More...
 
void deallocate (memory_block &block)
 Deallocates the given memory_block More...
 
bool owns (memory_block &block)
 Determines if the given memory_block is owned by this allocator. More...
 

Detailed Description

template<typename allocator, typename prefix, typename suffix = void, bool verify = false>
class boost::memory::affix_allocator< allocator, prefix, suffix, verify >

Allocator adding prefix and suffix objects in boundries of allocated block.

Template Parameters
allocatorThe underlying allocator performing physical memory_block allocation for the requested block, prefix and suffix.
prefixPrefix type, it has to be a default constructable type. An instance of this type will be constructed just before requested block on allocate and destroyed on deallocate.
suffixSuffix type, it has to be a default constructable type. An instance of this type will be constructed just before requested block on allocate and destroyed on deallocate.
verifyA boolean parameter indicating if prefix/suffix destructors should be invoked on deallocate.

Definition at line 76 of file affix_allocator.hpp.

Member Function Documentation

template<typename allocator , typename prefix , typename suffix , bool verify>
memory_block boost::memory::affix_allocator< allocator, prefix, suffix, verify >::allocate ( std::size_t  size)
inline

Allocates a memory_block with configured affixes.

Allocates a memory block of the given size using underlying allocator. Additionally prefix and suffix objects are constructed before and after returned memory block. These can be used for any purpose - tracking, debugging buffer under and overrun issues.

Returns
An instance of memory_block for the allocated block or null block for situations when allocation is not possible.

Definition at line 76 of file affix_allocator.ipp.

template<typename allocator , typename prefix , typename suffix , bool verify>
void boost::memory::affix_allocator< allocator, prefix, suffix, verify >::deallocate ( memory_block block)
inline

Deallocates the given memory_block

Attempts to deallocate the given memory block by destroying prefix and suffix instances affiliated to this block, but only if verify==*true*. memory_block is reclaimed only if it is owned by the underlying allocator.

Parameters
blockThe memory_block to deallocate.

Definition at line 97 of file affix_allocator.ipp.

template<typename allocator , typename prefix , typename suffix , bool verify>
bool boost::memory::affix_allocator< allocator, prefix, suffix, verify >::owns ( memory_block block)
inline

Determines if the given memory_block is owned by this allocator.

Ownership is determined by checking ownership of the underlying allocator for the complete block with defined prefix and suffix.

Parameters
block
Returns
true if the block is owned by this allocator, false otherwise.

Definition at line 122 of file affix_allocator.ipp.


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