Wilfried Mestdagh wrote:
> Hello,
>
> I know that an exception handler destroy the Exception object, eg in
> this case it is automaticly free:
>
> try
> if Condition then
> raise Exception.Create('Foo');
> except
> on E: Exception do
> TriggerError(E);
> end;
>
> But question is what in this case:
>
> if Condition then begin
> E := Exception.Create('Foo');
> TriggerError(E);
> end;
>
> There is no Raise, no Exception block, so do I have to Free the
> Exception object here ?
>
> I never used this coding style, but now I have a case where it seems
> logic I do this, but I want to make sure I have no memory leaks. Or is
> this considered as bad coding ?
Depends on what happens inside TriggerError().
If that or nothing else raises E, then indeed E needs to be
explicitly deallocated, it's basically just a class instance at
that point.
However, if TriggerError ISN'T raising E, then I have to question
why you're using an exception in the first place?
Stephen Posey
[EMAIL PROTECTED]
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk