[#BloombergLP-bdlma-BufferManager]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::BufferManager
:relfileprefix: ../../
:mrdocs:

Memory manager that dispenses heterogeneous blocks from an external buffer&period;

== Synopsis

Declared in `&lt;bdlma&lowbar;buffermanager&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BufferManager;
----

== Description

This class implements a buffer manager that dispenses heterogeneous blocks of memory (of varying, user&hyphen;specified sizes) from an external buffer whose address and size are optionally supplied at construction&period; 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&period; Note that in no event will the buffer manager attempt to deallocate the external buffer&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlma/BufferManager/2constructor-0c6.adoc[`BufferManager`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlma/BufferManager/2destructor.adoc[`&#126;BufferManager`] [.small]#[destructor]#
| Destroy this buffer manager&period;
| xref:BloombergLP/bdlma/BufferManager/alignmentStrategy.adoc[`alignmentStrategy`] 
| Return the alignment strategy passed to this object at construction&period;
| xref:BloombergLP/bdlma/BufferManager/allocate.adoc[`allocate`] 
| Return a contiguous block of memory of the specified `size` (in bytes), or 0 on failure&period;
| xref:BloombergLP/bdlma/BufferManager/allocateRaw.adoc[`allocateRaw`] 
| Return a contiguous block of memory of the specified `size` (in bytes)&period;
| xref:BloombergLP/bdlma/BufferManager/buffer.adoc[`buffer`] 
| Return an address providing modifiable access to the buffer currently managed by this object, or 0 if this object currently manages no buffer&period;
| xref:BloombergLP/bdlma/BufferManager/bufferSize.adoc[`bufferSize`] 
| Return the size (in bytes) of the buffer currently managed by this object, or 0 if this object currently manages no buffer&period;
| xref:BloombergLP/bdlma/BufferManager/calculateAlignmentOffsetFromSize.adoc[`calculateAlignmentOffsetFromSize`] 
| Return the alignment offset for `address` for an allocation of `size`&period;
| xref:BloombergLP/bdlma/BufferManager/deleteObject.adoc[`deleteObject`] 
| Destroy the specified `object`&period;
| xref:BloombergLP/bdlma/BufferManager/deleteObjectRaw.adoc[`deleteObjectRaw`] 
| Destroy the specified `object`&period; Note that memory associated with `object` is not deallocated because there is no `deallocate` method in `BufferManager`&period;
| xref:BloombergLP/bdlma/BufferManager/expand.adoc[`expand`] 
| Expand the allocation at `address` to include the remaining buffer&period;
| xref:BloombergLP/bdlma/BufferManager/hasSufficientCapacity.adoc[`hasSufficientCapacity`] 
| Return whether the buffer can allocate a block of the specified `size`&period;
| xref:BloombergLP/bdlma/BufferManager/release.adoc[`release`] 
| Release all memory currently allocated through this buffer manager&period;
| xref:BloombergLP/bdlma/BufferManager/replaceBuffer.adoc[`replaceBuffer`] 
| Replace the managed buffer with `newBuffer` of `newBufferSize`&period;
| xref:BloombergLP/bdlma/BufferManager/reset.adoc[`reset`] 
| Reset this buffer manager to its default&hyphen;constructed state&period;
| xref:BloombergLP/bdlma/BufferManager/truncate.adoc[`truncate`] 
| Truncate the allocation at `address` from `originalSize` to `newSize`&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
