[#BloombergLP-bslma-TestAllocator-allocate-04]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::xref:BloombergLP/bslma/TestAllocator.adoc[TestAllocator]::allocate
:relfileprefix: ../../../
:mrdocs:

Return a newly&hyphen;allocated block of memory of the specified `size`&period;

== Synopsis

Declared in `&lt;bslma&lowbar;testallocator&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;
----

== Description

Return a newly&hyphen;allocated block of memory of the specified `size` (in bytes)&period; If `size` is 0, a null pointer is returned&period; Otherwise, invoke the `allocate` method of the allocator supplied at construction, increment the number of currently (and cumulatively) allocated blocks, and increase the number of currently allocated bytes by `size`&period; Update all other fields accordingly&semi; if the allocation fails via an exception, `numAllocations()` is incremented, `lastAllocatedNumBytes()` is set to `size`, and `lastDeallocatedAddress()` is set to 0&period;

== Return Value

newly&hyphen;allocated block of `size` bytes, or null if `size` is 0

== Parameters

[cols="1,4"]
|===
| Name| Description
| *size*
| Number of bytes to allocate&period;
|===


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