[#BloombergLP-bslma-BufferAllocator-allocate-05] = 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). If `size` is 0, a null pointer is returned with no other effect. 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); if no callback function was specified, throw a `std::bad_alloc` exception in an exception‐enabled build, or else abort the program in a non‐exception build. The behavior is undefined unless `0 <= size`. Note that the alignment of the address returned depends on the alignment strategy (`MAXIMUM_ALIGNMENT` or `NATURAL_ALIGNMENT`) specified at construction of this buffer allocator. 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. == Synopses Declared in `<bslma_bufferallocator.h>` Return a newly allocated block of memory of (at least) the specified positive `size` (in bytes). If `size` is 0, a null pointer is returned with no other effect. 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); if no callback function was specified, throw a `std::bad_alloc` exception in an exception‐enabled build, or else abort the program in a non‐exception build. The behavior is undefined unless `0 <= size`. Note that the alignment of the address returned depends on the alignment strategy (`MAXIMUM_ALIGNMENT` or `NATURAL_ALIGNMENT`) specified at construction of this buffer allocator. 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- virtual void* xref:BloombergLP/bslma/BufferAllocator/allocate-0e.adoc[allocate](xref:BloombergLP/bslma/Allocator/size_type.adoc[size_type] size) override; ---- [.small]#xref:BloombergLP/bslma/BufferAllocator/allocate-0e.adoc[_» more..._]# [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] void* xref:BloombergLP/bslma/Allocator/allocate-034.adoc[allocate]( size_t __bytes, size_t __alignment = _S_max_align); ---- [.small]#xref:BloombergLP/bslma/Allocator/allocate-034.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#