"Dass die Methode Free auf nil prüft" ist auch falsch. FreeAndNil prüft dagegen.
Du irrst gewaltig! In beiden Fällen!
Delphi-Quellcode:
procedure TObject.Free;
begin
// under ARC, this method isn't actually called since the compiler translates
// the call to be a mere nil assignment to the instance variable, which then calls _InstClear
{$IFNDEF AUTOREFCOUNT}
if Self <> nil then
Destroy;
{$ENDIF}
end;
Delphi-Quellcode:
procedure FreeAndNil(var Obj);
{$IF not Defined(AUTOREFCOUNT)}
var
Temp: TObject;
begin
Temp := TObject(Obj);
Pointer(Obj) := nil;
Temp.Free;
end;
{$ELSE}
begin
TObject(Obj) := nil;
end;
{$ENDIF}