Posted without comment:

Posted without comment:

if assigned(MO) then FreeAndNil(MO);

Okay, one comment:  all on one line.

Comments

  1. baaah, I can do better!!

    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;

    100 points if you guess the outcome (:

    ReplyDelete

Post a Comment