System.SysUtils.AnsiStrAlloc

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function AnsiStrAlloc(Size: Cardinal): PAnsiChar;

C++

extern DELPHI_PACKAGE char * __fastcall AnsiStrAlloc _DEPRECATED_ATTRIBUTE1("Moved to the AnsiStrings unit") (unsigned Size);

Properties

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

Description

Warning: AnsiStrAlloc is deprecated. Please use AnsiStrings.

Allocates a buffer for a null-terminated AnsiString and returns a pointer to its first character.

AnsiStrAlloc allocates a buffer for a null-terminated AnsiString with a maximum length of Size - 1 (1 byte must be reserved for the termination character). The result points to the location where the first character of the string is to be stored. A 32-bit number giving the total amount of memory allocated is stored in the four bytes preceding the first character; it is equal to Size + 4. If the space for a string is allocated with AnsiString, it should be deallocated via StrDispose.

Because AnsiStrings are implicitly null terminated and dynamically allocated, the use of AnsiStrAlloc is deprecated.

See Also