|
BDE 4.39.x Production Release
|
#include <bdlma_guardingallocator.h>
This class defines a concrete thread-safe "guarding" allocator mechanism that implements the bslma::Allocator protocol, and adjoins a read/write protected guard page to each block of memory returned by the allocate method. The guard page is placed immediately before or immediately following the block returned from allocate according to the GuardPageLocation enumerator value (optionally) supplied at construction.
Public Types | |
| enum | GuardPageLocation { e_AFTER_USER_BLOCK , e_BEFORE_USER_BLOCK } |
Public Types inherited from bslma::Allocator | |
| typedef std::size_t | size_type |
Public Member Functions | |
| GuardingAllocator (GuardPageLocation guardLocation=e_AFTER_USER_BLOCK) | |
| ~GuardingAllocator () BSLS_KEYWORD_OVERRIDE | |
| void * | allocate (bsls::Types::size_type size) BSLS_KEYWORD_OVERRIDE |
| void | deallocate (void *address) BSLS_KEYWORD_OVERRIDE |
Public Member Functions inherited from bslma::Allocator | |
| ~Allocator () BSLS_KEYWORD_OVERRIDE | |
| template<class TYPE > | |
| void | deleteObject (const TYPE *object) |
| template<class TYPE > | |
| void | deleteObjectRaw (const TYPE *object) |
| void | deleteObject (bsl::nullptr_t) |
| void | deleteObjectRaw (bsl::nullptr_t) |
Public Member Functions inherited from bsl::memory_resource | |
| memory_resource () BSLS_KEYWORD_DEFAULT | |
| memory_resource (const memory_resource &) BSLS_KEYWORD_DEFAULT | |
| virtual | ~memory_resource () |
| memory_resource & | operator= (const memory_resource &) BSLS_KEYWORD_DEFAULT |
| BSLA_NODISCARD void * | allocate (size_t bytes, size_t alignment=k_MAX_ALIGN) |
| void | deallocate (void *p, size_t bytes, size_t alignment=k_MAX_ALIGN) |
| bool | is_equal (const memory_resource &other) const BSLS_KEYWORD_NOEXCEPT |
Additional Inherited Members | |
Static Public Member Functions inherited from bslma::Allocator | |
| static void | throwBadAlloc () |
Protected Member Functions inherited from bslma::Allocator | |
| void * | do_allocate (std::size_t bytes, std::size_t alignment) BSLS_KEYWORD_OVERRIDE |
| void | do_deallocate (void *p, std::size_t bytes, std::size_t alignment) BSLS_KEYWORD_OVERRIDE |
| bool | do_is_equal (const memory_resource &other) const BSLS_KEYWORD_NOEXCEPT BSLS_KEYWORD_OVERRIDE |
Enumerate the configuration options for GuardingAllocator that may be (optionally) supplied at construction.
| Enumerator | |
|---|---|
| e_AFTER_USER_BLOCK | |
| e_BEFORE_USER_BLOCK | |
|
inlineexplicit |
Create a guarding allocator. Optionally specify a guardLocation indicating where read/write protected guard pages should be placed with respect to the memory blocks returned by the allocate method. If guardLocation is not specified, guard pages are placed immediately following the memory blocks returned by allocate.
| bdlma::GuardingAllocator::~GuardingAllocator | ( | ) |
Destroy this allocator object.
|
virtual |
Return a newly-allocated maximally-aligned block of memory of the specified size (in bytes) that has a read/write protected guard page located immediately before or after it according to the GuardPageLocation indicated at construction. If size is 0, no memory is allocated and 0 is returned.
Implements bslma::Allocator.
|
virtual |
Return the memory block at the specified address back to this allocator. If address is 0, this method has no effect. Otherwise, the guard page associated with address is unprotected and also deallocated.
address was returned by allocate and has not already been deallocated. Implements bslma::Allocator.