How to detect “dangling pointers” if “Assigned()” can't do it?

后端 未结 6 1664
闹比i
闹比i 2020-12-03 17:22

In another question, I found out that the Assigned() function is identical to Pointer <> nil. It has always been my understanding that

6条回答
  •  渐次进展
    2020-12-03 18:09

    Nothing can find a dangling (once valid but then not) pointer. It's your responsibility to either make sure it's set to nil when you free it's content, or to limit the scope of the pointer variable to only be available within the scope it's valid. (The second is the better solution whenever possible.)

提交回复
热议问题