Re: Error on deleting pointer
Re: Error on deleting pointer
- Subject: Re: Error on deleting pointer
- From: "Ray, Jeffrey R. {Jeff}(DFRC-ME)" <email@hidden>
- Date: Mon, 12 Sep 2011 13:02:54 -0500
- Acceptlanguage: en-US
- Thread-topic: Error on deleting pointer
On 9/12/11 7:49 AM, "Jos Timanta Tarigan" <email@hidden> wrote:
> Hi,
>
> I seems not to understand what went wrong with my code. I use guard malloc and
> it catches this error when I delete the pointer in the destructor of an
> object.
>
> ~ObjectX() {
> delete [] bgArr; // malloc error occured here
> };
>
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;
}
This gets rid of the reported error, and if you add a bit of debugging code
around at the delete(s), it might help track down where the extra delete is
coming from.
What exactly are you doing with bgArr? Are you passing it to some library
that thinks it now owns it, and might be deleting it without your knowledge?
-j
------------------------------------------------------------------
Jeff Ray M/S 4840A Official Correspondence Only:
NASA email@hidden
Dryden Flight Research Center email@hidden
P. O. Box 273
Edwards, CA 93523-0273 All Others: email@hidden
(661) 276-3754
_______________________________________________
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