Here is a list of "string" type definitions:
 |
type
TPString = ^string;
TAString = array [0..maxInt shr 2-1] of string;
TPAString = ^TAString;
TDAString = array of string;
TPDAString = ^TDAString;
|
|
Please note, that allocating and freeing "TPString" or "TPAString" variables
is a bit dangerous. You have to know exactly what you're doing. So please
look at the following examples, which show wrong and right ways.
 |
procedure Proc1;
var pStrVar : TPString;
begin
GetMem(pStrVar, sizeOf(string));
pStrVar^ := 'test';
end;
procedure Proc2;
var pStrVar : TPString;
begin
GetMem(pStrVar, sizeOf(string));
ZeroMemory(pStrVar, sizeOf(string));
pStrVar^ := 'test';
FreeMem(pStrVar);
end;
procedure Proc3;
var pStrVar : TPString;
begin
pStrVar := AllocMem(sizeOf(string));
pStrVar^ := 'test';
Finalize(pStrVar);
FreeMem(pStrVar);
end;
procedure Proc4;
begin
New(pStrVar);
pStrVar^ := 'test';
Dispose(pStrVar);
end;
|
|