BloombergLP::bdlb::String::copy

Return a newly allocated null-terminated copy of string.

Synopsis

Declared in <bdlb_string.h>

static
char*
copy(
    bsl::string const& string,
    bslma::Allocator* basicAllocator);

Description

Create a null-terminated copy of the specified string, using the specified basicAllocator to supply memory, and return the address of the newly-created modifiable string. The string that is returned is owned by the caller. The behavior is undefined unless string.size() <= INT_MAX and basicAllocator is non-null. Note that if string contains any embedded null ('0') characters they will be propagated to the copy.

Return Value

address of the newly allocated copy

Parameters

NameDescription
stringstring to copy
basicAllocatorallocator used to supply memory