Language:
Русский
English
{Fail.PAS}
▀▀▀▀▀▀▀▀▀▀▀▀
{Sample code for the Fail procedure. }
{F+}
function HeapFunc(Size: word): Integer;
begin
HeapFunc := 1; { Return nil if out of heap }
end;
{$F-}
type
CharPtr: ^char;
BigString = object { Holds big strings }
len: word;
txt: CharPtr;
constructor Init(size: word;
contents: CharPtr);
procedure Show;
...
destructor Done;
end;
constructor BigString.Init(size: word;
contents: CharPtr);
begin
len := size;
GetMem(txt,size);
if txt = nil then
Fail; { Quit and indicate failure }
Move(contents^,txt^,size);
end;
destructor BigString.Done;
begin
FreeMem(txt,len);
end;