[Lazarus] Difference between FreeThenNil and FreeAndNil

Bernd prof7bit at googlemail.com
Wed Apr 27 12:07:50 CEST 2011


2011/4/27 Alexander Klenin <klenin at gmail.com>:

> No, the destructor can not change the object pointer.
> That is the whole point.

It does not even know which or how many variables are pointing to it,
does it? If this is the case then what does it matter which ones of
them are set to nil before or after it is freed?

In FreeAndNil it is first freeing the object while the there still
exists a reference to it (temp). But the object does not know about
temp or var obj anyways and has no reference to any of them (where
should it have leaned about them in the first place?), or does it?

So IMHO this pocedure is essentially doing exactly the same as the
FreeThenNil procedure. At least that is how I understand it.




More information about the Lazarus mailing list