RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.StrAlloc Function

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

Pascal
function StrAlloc(Size: Cardinal): PChar;
C++
const char * StrAlloc(unsigned Size);

SysUtils

StrAlloc allocates a buffer for a null-terminated string 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 space for a string is allocated with StrAlloc, it should be deallocated via StrDispose

Because AnsiStrings (long strings) are implicitly null terminated and dynamically allocated, the use of StrAlloc is deprecated. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!