Every Tobject created will have 0, nil null, values assigned to members on creation.
class function TObject.NewInstance : tobject; var p : pointer; begin getmem(p, InstanceSize); if p <> nil then InitInstance(p); NewInstance:=TObject(p); end; class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF} begin { the size is saved at offset 0 } fillchar(instance^, InstanceSize, 0); { insert VMT pointer into the new created memory area } { (in class methods self contains the VMT!) } ppointer(instance)^:=pointer(self); if PVmt(self)^.vIntfTable <> @emptyintf then InitInterfacePointers(self,instance); InitInstance:=TObject(Instance); end;
No zeroing going on at all...Seems a bit different from delphi...?
Quote from: cdbc on March 12, 2011, 04:10:46 amNo zeroing going on at all...Seems a bit different from delphi...?Yep, you're right here, that was one of the Delphi caveats: don't initialize variables before having called the inherited constructor.
??? as laksen wrote, all classes are initialized to zero (opposite to objects)