Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Static Public Member Functions

bdlma::LocalSequentialAllocator< t_SIZE > Class Template Reference

#include <bdlma_localsequentialallocator.h>

Inheritance diagram for bdlma::LocalSequentialAllocator< t_SIZE >:
bdlma::BufferedSequentialAllocator bdlma::ManagedAllocator bslma::Allocator

List of all members.

Public Types

typedef bsls::Types::size_type size_type

Public Member Functions

virtual void * allocate (size_type size)
virtual void deallocate (void *address)
virtual void release ()
virtual void rewind ()
template<class TYPE >
void deleteObject (const TYPE *object)
void deleteObject (bsl::nullptr_t)
template<class TYPE >
void deleteObjectRaw (const TYPE *object)
void deleteObjectRaw (bsl::nullptr_t)

Static Public Member Functions

static void throwBadAlloc ()

Detailed Description

template<int t_SIZE>
class bdlma::LocalSequentialAllocator< t_SIZE >

This class implements the ManagedAllocator protocol to provide a fast allocator that dispenses heterogeneous blocks of memory (of varying, user-specified sizes) from a local buffer whose capacity is the specified t_SIZE (in bytes). If an allocation request exceeds the remaining free memory space in the local buffer, memory will be supplied by an (optional) allocator supplied at construction; if no allocator is supplied, the currently installed default allocator is used. This class is exception neutral; if memory cannot be allocated, the behavior is defined by the (optional) allocator supplied at construction.

See Component bdlma_localsequentialallocator


Member Typedef Documentation


Member Function Documentation

virtual void* bdlma::BufferedSequentialAllocator::allocate ( size_type  size  )  [virtual, inherited]

Return the address of a contiguous block of memory of the specified size (in bytes) according to the alignment strategy specified at construction. If size is 0, no memory is allocated and 0 is returned. If the allocation request exceeds the remaining free memory space in the external buffer supplied at construction, use memory obtained from the allocator supplied at construction.

Implements bslma::Allocator.

virtual void bdlma::BufferedSequentialAllocator::deallocate ( void *  address  )  [virtual, inherited]

This method has no effect on the memory block at the specified address as all memory allocated by this allocator is managed. The behavior is undefined unless address is 0, or was allocated by this allocator and has not already been deallocated. The effect of using address after this call is undefined.

Implements bslma::Allocator.

virtual void bdlma::BufferedSequentialAllocator::release (  )  [virtual, inherited]

Release all memory allocated through this allocator and return to the underlying allocator all memory except the external buffer supplied at construction. The allocator is reset to its default-constructed state, making the memory from the entire external buffer supplied at construction available for subsequent allocations, retaining the alignment and growth strategies, and the initial and maximum buffer sizes in effect following construction. The effect of subsequently - to this invokation of release - using a pointer obtained from this object prior to this call to release is undefined.

Implements bdlma::ManagedAllocator.

virtual void bdlma::BufferedSequentialAllocator::rewind (  )  [virtual, inherited]

Release all memory allocated through this allocator and return to the underlying allocator only memory that was allocated outside of the typical internal buffer growth of this allocator (i.e., large blocks). All retained memory will be used to satisfy subsequent allocations. The effect of subsequently - to this invokation of rewind - using a pointer obtained from this object prior to this call to rewind is undefined.

static void bslma::Allocator::throwBadAlloc (  )  [static, inherited]

DEPRECATED: Use bsls::BslExceptionUtil::throwBadAlloc instead.

Throw std::bad_alloc if exceptions are enabled or abort the program otherwise. Derived classes and helper functions will typically call this function when they are unable to satisfy an allocation request. This function never returns.

template<class TYPE >
void bslma::Allocator::deleteObject ( const TYPE *  object  )  [inherited]

Destroy the specified object based on its dynamic type and then use this allocator to deallocate its memory footprint. Do nothing if object is a null pointer. The behavior is undefined unless object, when cast appropriately to void *, was allocated using this allocator and has not already been deallocated. Note that dynamic_cast<void *>(object) is applied if TYPE is polymorphic, and static_cast<void *>(object) is applied otherwise.

void bslma::Allocator::deleteObject ( bsl::nullptr_t   )  [inherited]

This function has no effect. Note that it exists to support calling deleteObject will a null pointer literal, that would otherwise not deduce to a pointer type for the method above. As calls to deleteObject with (typed) null pointer values have well-defined behavior, it should also support calls with a null pointer literal.

template<class TYPE >
void bslma::Allocator::deleteObjectRaw ( const TYPE *  object  )  [inherited]

Destroy the specified object and then use this allocator to deallocate its memory footprint. Do nothing if object is a null pointer. The behavior is undefined unless object was allocated using this allocator, is not a secondary base class pointer -- i.e., the address is (numerically) the same as when it was originally dispensed by this allocator, and has not already been deallocated.

void bslma::Allocator::deleteObjectRaw ( bsl::nullptr_t   )  [inherited]

This function has no effect. Note that it exists to support calling deleteObjectRaw will a null pointer literal, that would otherwise not deduce to a pointer type for the method above. As calls to deleteObjectRaw with (typed) null pointer values have well-defined behavior, it should also support calls with a null pointer literal.


Member Data Documentation

template<int t_SIZE>
char bdlma::LocalSequentialAllocator< t_SIZE >::d_buffer[t_SIZE]
template<int t_SIZE>
AlignmentType bdlma::LocalSequentialAllocator< t_SIZE >::d_align

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