• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Error on deleting pointer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Error on deleting pointer
      • From: Andreas Grosam <email@hidden>
References: 
 >Re: Error on deleting pointer (From: Jos Timanta Tarigan <email@hidden>)
 >Re: Error on deleting pointer (From: "Ray, Jeffrey R. {Jeff}(DFRC-ME)" <email@hidden>)
 >Re: Error on deleting pointer (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: [Xcode 4.1] Is there any way to speed up code complete?
  • Next by Date: Re: Xcode 4.1: Sorting files in groups
  • Previous by thread: Re: Error on deleting pointer
  • Next by thread: Re: Error on deleting pointer
  • Index(es):
    • Date
    • Thread