Hi Rohit,

That is five lines of code.

The demo code I show was one line code.

Regards
Leigh

-----Original Message-----
From: Rohit Gupta [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 23 November 2005 1:36 p.m.
To: [EMAIL PROTECTED]; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] FreeAndNil for TAutoObject in Delphi 5


Leigh,

whats worng with

if assigned (aAutoObject)
then begin
    aAutoObject.Free;
    aAutoObject := nil;
end;

Leigh Wanstead wrote:

>Hello everyone,
>
>I plan to write a method similar to Delphi7 freeandnil procedure, but for
>TAutoObject in Delphi 5 version.
>
>Here is the prototype code.
>
>procedure STTAutoObjectRelease(var aAutoObject: TAutoObject);
>var
>  varAutoObject: TAutoObject;
>begin
>  varAutoObject := aAutoObject;
>  if varAutoObject = nil then
>  begin
>    Exit;
>  end;
>
>  TObject(aAutoObject) := nil;  // clear the reference before destroying
the
>object
>  varAutoObject.release;
>end;
>
>But the issue is I worried about TAutoObject will be like interface, every
>time pass between method, auto increment, decrement reference counting.
That
>make this method to complex to decide.
>
>The normal way to do is like here.
>  if assigned(fAutoObject) then
>  begin
>    fAutoObject.Release;
>  end;
>
>But that is three lines code.
>
>Here is what I proposed to do.
>
>STTAutoObjectRelease(fAutoObject);
>
>TIA
>
>Regards
>Leigh
>http://www.salenz.com
>
>
>_______________________________________________
>Delphi mailing list
>[email protected]
>http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
>
>




_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to