In another question, I found out that the Assigned()
function is identical to Pointer <> nil
. It has always been my understanding that Assigned()
was detecting these dangling pointers, but now I've learned it does not. Dangling Pointers are those which may have been created at one point, but have since been free'd and haven't been assigned to nil
yet.
If Assigned()
can't detect dangling pointers, then what can? I'd like to check my object to make sure it's really a valid created object before I try to work with it. I don't use FreeAndNil
as many recommend, because I like to be direct. I just use SomeObject.Free
.
Access Violations are my worst enemy - I do all I can to prevent their appearance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…