System.AnsiStrings.StrNew

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function StrNew(const Str: PAnsiChar): PAnsiChar;

C++

extern DELPHI_PACKAGE char * __fastcall StrNew(const char * Str)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.AnsiStrings.pas
System.AnsiStrings.hpp
System.AnsiStrings System.AnsiStrings

Description

Allocates space on and copies a string to the heap, returning a pointer to the string.

StrNew allocates a copy of Str on the heap.

If Str is nil (Delphi) or NULL (C++) or points to an empty string, StrNew returns a pointer to a new empty string.

Otherwise, StrNew makes a duplicate of Str, obtaining space with a call to StrAlloc and returns a pointer to the duplicated string.

The allocated space is the length of Str + 5 bytes.

See Also

Code Examples