[Original] Delphi FreeAndNil is a process, not a function

 Delphi FreeAndNil is a process, not a function, see the source code, we know that its main role is to clear and release objects

procedure FreeAndNil(var Obj);
var
  Temp: TObject;
begin
  Temp := TObject(Obj);
  Pointer(Obj) := nil;
  Temp.Free;
end;

See execution code sequence, the first blank, and release

Blanking  clear pointer to the memory address.

Release to release all resource instances occupied. After the Free, the pointer can not be used

 

 

Updated: 2019.12.27

From: https: //www.cnblogs.com/guorongtao/p/12107245.html

Guess you like

Origin www.cnblogs.com/guorongtao/p/12107245.html