[#BloombergLP-bslma-BufferAllocator-allocate-0e]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/BufferAllocator.adoc[BufferAllocator]::allocate
:relfileprefix: ../../../
:mrdocs:

Return a newly allocated block of memory of (at least) the specified positive `size` (in bytes)&period; If `size` is 0, a null pointer is returned with no other effect&period; If this allocator cannot return the requested number of bytes, then it will return the result of invoking an optional callback function (supplied at construction)&semi; if no callback function was specified, throw a `std&colon;&colon;bad&lowbar;alloc` exception in an exception&hyphen;enabled build, or else abort the program in a non&hyphen;exception build&period; The behavior is undefined unless `0 &lt;&equals; size`&period; Note that the alignment of the address returned depends on the alignment strategy (`MAXIMUM&lowbar;ALIGNMENT` or `NATURAL&lowbar;ALIGNMENT`) specified at construction of this buffer allocator&period; Also note that it is up to the callback function whether to return zero or throw an exception if this buffer allocator is unable to satisfy the request&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
virtual
void*
allocate(xref:BloombergLP/bslma/Allocator/size_type.adoc[size&lowbar;type] size) override;
----


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