Language:
Русский
English
{StrMove.PAS}
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
{Sample code for the StrMove and StrDispose functions.}
{ Allocate string on heap }
function StrNew(S: PChar): PChar;
var
L: Word;
P: PChar;
begin
if (S = nil) or (S^ = #0) then StrNew := nil else
begin
L := StrLen(S) + 1;
GetMem(P, L);
StrNew := StrMove(P, S, L);
end;
end;
{ Dispose string on heap }
procedure StrDispose(S: PChar);
begin
if S <> nil then FreeMem(S, StrLen(S) + 1);
end;