[#BloombergLP-bdlma-BufferManager-replaceBuffer]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlma.adoc[bdlma]::xref:BloombergLP/bdlma/BufferManager.adoc[BufferManager]::replaceBuffer
:relfileprefix: ../../../
:mrdocs:

Replace the managed buffer with `newBuffer` of `newBufferSize`&period;

== Synopsis

Declared in `&lt;bdlma&lowbar;buffermanager&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
char*
replaceBuffer(
    char* newBuffer,
    xref:BloombergLP/bsls/Types/size_type.adoc[bsls::Types::size&lowbar;type] newBufferSize);
----

== Description

Replace the buffer currently managed by this object with the specified `newBuffer` of the specified `newBufferSize` (in bytes)&semi; return the address of the previously held buffer, or 0 if this object currently manages no buffer&period; The replaced buffer (if any) is removed from the management of this object with no effect on the outstanding allocated memory blocks&period; Subsequent allocations will allocate memory from the beginning of the new external buffer&period; The behavior is undefined unless `0 &lt; newBufferSize` and `newBuffer` has at least `newBufferSize` bytes&period;

== Return Value

address of the previously held buffer, or 0 if this object currently manages no buffer

== Parameters

[cols="1,4"]
|===
| Name| Description
| *newBuffer*
| external buffer to manage
| *newBufferSize*
| size in bytes of `newBuffer`
|===


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