Re: Error on deleting pointer
Re: Error on deleting pointer
- Subject: Re: Error on deleting pointer
- From: Jean-Denis MUYS <email@hidden>
- Date: Tue, 13 Sep 2011 07:24:01 +0000
- Thread-topic: Error on deleting pointer
On 12 sept. 2011, at 22:51, Sean McBride wrote:
On
Mon, 12 Sep 2011 13:02:54 -0500, Ray, Jeffrey R. {Jeff}(DFRC-ME) said:
This won't help you with finding where the problem is, but you might
consider adopting the coding style of setting invalid pointers to zero:
if(pointer){
delete pointer;
pointer = 0;
}
The 'if' is not needed as the standard guarantees that 'delete NULL' does nothing. Setting the pointer to 0 afterwards can indeed be a good idea.
An argument could be made that setting the pointer to NULL would tend to hide the bug not correct it. If on the contrary you want the bug to be exposed as early and systematically as possible, it would be better to use another constant. To that effect,
I typically use:
pointer = (void*)0xDeadBeef;
Jean-Denis
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden