Vote UpVote

Yet Another Word about FreeAndNil

The Programming Works – The FreeAndNil discussion never stops. I decided to add my twopence. How about this: {.$DEFINE FREEANDNIL} {$IFDEF FREEANDNIL} procedure FreeObj(var Obj); inline; begin FreeAndNil(Obj); end; {$ELSE} procedure FreeObj(Obj: TObject); inline; begin Obj.Free; end; {$ENDIF} With FreeObj procedure you can have both “defensive coding” for debugging and clean production code. It is also clear that FreeAndNil is used just for debugging, so future maintainers will not be mislead and distracted by FreeAndNil usage. Since FreeObj is inlined, it does not also have an influence on the executable code ...
Favorite? Off-Topic? Serg @ 2011-12-14 09:16


Visits: 1191
Votes: 1
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Alister Christie
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)