unit A; ///... procedure FreeAndNilAssigned(var Obj); begin if Assigned(Obj) then FreeAndNil(Obj); end; ///... end.
unit B; ///... procedure FreeAndNilAssigned(var Obj); begin //if Assigned(Obj) then -- NO LONGER NEEDED! FreeAndNil(Obj); end; unit C; ///... uses A, B; ///... var LObj: TObject; begin FreeAndNilAssigned(LObj); end;
baaah, I can do better!!
ReplyDeleteunit A;
///...
procedure FreeAndNilAssigned(var Obj);
begin
if Assigned(Obj) then
FreeAndNil(Obj);
end;
///...
end.
unit B;
///...
procedure FreeAndNilAssigned(var Obj);
begin
//if Assigned(Obj) then -- NO LONGER NEEDED!
FreeAndNil(Obj);
end;
unit C;
///...
uses A, B;
///...
var
LObj: TObject;
begin
FreeAndNilAssigned(LObj);
end;
100 points if you guess the outcome (:
Very nice. Have it framed!
ReplyDelete