FreeAndNil

From Free Pascal wiki
Revision as of 11:20, 19 August 2016 by FPC user (talk | contribs) (classes only)
Jump to navigationJump to search

FreeAndNil is a procedure defined in the SysUtils unit of the Free Pascal Runtime Library. It calls an object's constructor (via TObject.Free) and also sets the object variable (which is a reference to heap memory created by a constructor call) to nil. If you just call an object's destructor, Assigned will still return True for the object variable. But after calling FreeAndNil, Assigned will return False for the object variable. While the procedure has an untyped parameter, it is only for use with object references - that is variables that are instances of a Class.

procedure FreeAndNil( var obj );