[#BloombergLP-bdlb-String-copy-0e0]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/String.adoc[String]::copy
:relfileprefix: ../../../
:mrdocs:

Return a newly allocated null&hyphen;terminated copy of `string`&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;string&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
char*
copy(
    char const* string,
    int length,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator);
----

== Description

Create a null&hyphen;terminated copy of the specified `string` having the specified `length` (in bytes), using the specified `basicAllocator` to supply memory, and return the address of the newly&hyphen;created modifiable string&period; The string that is returned is owned by the caller&period; The behavior is undefined unless `0 &lt;&equals; length` and `basicAllocator` is non&hyphen;null&period; Note that if `string` contains any embedded null (&apos;0&apos;) characters they will be propagated to the copy&period;

== Return Value

address of the newly allocated copy

== Parameters

[cols="1,4"]
|===
| Name| Description
| *string*
| string to copy
| *length*
| length of `string` in bytes
| *basicAllocator*
| allocator used to supply memory
|===


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