[fpc-pascal] Generic way to pre-maturely exit TCustomApplication without memory leaks
grouchysmurf
d7559b8c502dea1b5323af444e81e014 at grabun.pl
Wed Oct 12 21:37:48 CEST 2016
Hi.
Is there a way to pre-maturely halt TCustomApplication without causing
memory leaks?
Say, I have a code, where TH is a Class(TCustomApplication):
ph := TH.Create(Nil);
ph.Initialize;
ph.ProcessOptions;
ph.Run;
ph.Free;
When options are processed, it may happen the program needs to halt,
when provided with improper parameters, for example. In such a case,
I would call Help method:
Procedure TH.Help(ExitCode : Byte = 0; ErrStr : String = '');
Begin
{ do stuff }
Halt(ExitCode);
End;
Now, when this happens, ph is not freed, causing a minor memory leak.
I don't want that. Is there a way to terminate a program with Halt but
also making sure the memory has been freed properly?
Thanks.
Ćukasz
More information about the fpc-pascal
mailing list