[#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 `buffer`. == Synopsis Declared in `<bslma_bufferallocator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static void* allocateFromBuffer( int* cursor, char* buffer, xref:BloombergLP/bslma/Allocator/size_type.adoc[size_type] bufSize, xref:BloombergLP/bslma/Allocator/size_type.adoc[size_type] size, xref:BloombergLP/bslma/BufferAllocator/AlignmentStrategy.adoc[AlignmentStrategy] strategy); ---- == Description Allocate a memory block of the specified `size` from the specified `buffer` at the specified `cursor` position. Return the address of the allocated memory block if `buffer` contains enough available memory, and `null` otherwise. The `cursor` is set to the index of the next available byte in `buffer` after the allocation. Use the specified alignment `strategy` (or `alignment` value) to allocate memory. If `size` is 0, do not allocate memory and return zero. The behavior is undefined unless `0 < = bufSize`, `0 <= size`, `0 < alignment <= bsls::AlignmentUtil::BSLS_MAX_ALIGNMENT`, and alignment is an integral power of 2. == Return Value address of the allocated block, or null if insufficient space == Parameters [cols="1,4"] |=== | Name| Description | *cursor* | Index of the next available byte in `buffer` (in/out). | *buffer* | Memory buffer from which to allocate. | *bufSize* | Size (in bytes) of `buffer`. | *size* | Number of bytes to allocate. | *strategy* | Alignment strategy used for the allocation. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#