Language:
Русский
English
{FreeMem.PAS}
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
{Sample code for the FreeMem and GetMem procedures and the MaxAvail
function.}
uses WinCrt;
type
TFriendRec = record
Name: string[30];
Age : Byte;
end;
var
p: pointer;
begin
if MaxAvail < SizeOf(TFriendRec) then
Writeln('Not enough memory')
else
begin
{ Allocate memory on heap }
GetMem(p, SizeOf(TFriendRec));
{ ...}
{ ...Use the memory... }
{ ...}
{ Then free it when done }
FreeMem(p, SizeOf(TFriendRec));
end;
end.