[#BloombergLP-bslma-BufferAllocator-allocateFromBuffer-06]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/BufferAllocator.adoc[BufferAllocator]::allocateFromBuffer
:relfileprefix: ../../../
:mrdocs:

Allocate a memory block of the specified `size` from the specified `buffer` at the specified `cursor` position&period; Return the address of the allocated memory block if `buffer` contains enough available memory, and `null` otherwise&period; The `cursor` is set to the index of the next available byte in `buffer` after the allocation&period; Use the specified alignment `strategy` (or `alignment` value) to allocate memory&period; If `size` is 0, do not allocate memory and return zero&period; The behavior is undefined unless `0 &lt; &equals; bufSize`, `0 &lt;&equals; size`, `0 &lt; alignment &lt;&equals; bsls&colon;&colon;AlignmentUtil&colon;&colon;BSLS&lowbar;MAX&lowbar;ALIGNMENT`, and alignment is an integral power of 2&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
void*
allocateFromBuffer(
    int* cursor,
    char* buffer,
    xref:BloombergLP/bslma/Allocator/size_type.adoc[size&lowbar;type] bufSize,
    xref:BloombergLP/bslma/Allocator/size_type.adoc[size&lowbar;type] size,
    xref:BloombergLP/bslma/BufferAllocator/AlignmentStrategy.adoc[AlignmentStrategy] strategy);
----


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