Il 20/05/2019 15:23, James Richters ha scritto: Thank you very much for the explanation and examples of this! I am glad you pointed out the FreeAndNill() function, I will defiantly be needing that.James Then you might also appreciate the function Assigned. Assigned(P) returns true if P is non-nil, and false if P is Nil. Nothing fancy, just making the code more readable. From fpc documentation: GiulianoProgram Example96; { Program to demonstrate the Assigned function. } Var P : Pointer; begin If Not Assigned(P) then Writeln ('Pointer is initially NIL'); P:=@P; If Not Assigned(P) then Writeln('Internal inconsistency') else Writeln('All is well in FPC') end. P.S. In some rare case when dealing with complex objects you might need FreeThenNil() in place of FreeAndNil(). Give a look to https://lists.lazarus-ide.org/pipermail/lazarus/2011-April/062743.html -- Do not do to others as you would have them do to you.They might have different tastes. |
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal