[#BloombergLP-bslma-BufferAllocator-2constructor-0fc]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/BufferAllocator.adoc[BufferAllocator]::BufferAllocator
:relfileprefix: ../../../
:mrdocs:

Create a buffer allocator that allocates from the specified `buffer`&period;

== Synopsis

Declared in `&lt;bslma&lowbar;bufferallocator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
BufferAllocator(
    char* buffer,
    xref:BloombergLP/bslma/Allocator/size_type.adoc[size&lowbar;type] bufSize,
    xref:BloombergLP/bslma/BufferAllocator/AllocCallback.adoc[AllocCallback] allocCallback = 0);
----

== Description

Create a buffer allocator for allocating memory blocks from the specified `buffer` of the specified `bufSize`&period; Optionally specify a callback function `allocCallback` that is invoked when a call to `allocate` cannot be fulfilled from `buffer`&period; Note that maximum alignment is used when allocating memory&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *buffer*
| Memory buffer from which to allocate&period;
| *bufSize*
| Size (in bytes) of `buffer`&period;
| *allocCallback*
| Optional callback invoked when allocation fails&period;
|===


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