Memory manager that dispenses heterogeneous blocks from an external buffer.

Synopsis

Declared in <bdlma_buffermanager.h>

class BufferManager;

Description

This class implements a buffer manager that dispenses heterogeneous blocks of memory (of varying, user‐specified sizes) from an external buffer whose address and size are optionally supplied at construction. If an allocation request exceeds the remaining free memory space in the external buffer, the allocation request returns 0 if allocate is used, or results in undefined behavior if allocateRaw is used. Note that in no event will the buffer manager attempt to deallocate the external buffer.

Member Functions

Name

Description

BufferManager [constructor]

Constructors

~BufferManager [destructor]

Destroy this buffer manager.

alignmentStrategy

Return the alignment strategy passed to this object at construction.

allocate

Return a contiguous block of memory of the specified size (in bytes), or 0 on failure.

allocateRaw

Return a contiguous block of memory of the specified size (in bytes).

buffer

Return an address providing modifiable access to the buffer currently managed by this object, or 0 if this object currently manages no buffer.

bufferSize

Return the size (in bytes) of the buffer currently managed by this object, or 0 if this object currently manages no buffer.

calculateAlignmentOffsetFromSize

Return the alignment offset for address for an allocation of size.

deleteObject

Destroy the specified object.

deleteObjectRaw

Destroy the specified object. Note that memory associated with object is not deallocated because there is no deallocate method in BufferManager.

expand

Expand the allocation at address to include the remaining buffer.

hasSufficientCapacity

Return whether the buffer can allocate a block of the specified size.

release

Release all memory currently allocated through this buffer manager.

replaceBuffer

Replace the managed buffer with newBuffer of newBufferSize.

reset

Reset this buffer manager to its default‐constructed state.

truncate

Truncate the allocation at address from originalSize to newSize.

Created with MrDocs