Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a "user breakpoint..." message error i don't understand

Status
Not open for further replies.

jayjay60

Programmer
Jun 19, 2001
97
FR
Hi everybody,

In my application i have created a simple function which delete memory of specific pointer, you could find its following code:

void LoadHistoDB::DeleteHistoNorm()
{
if(pHistoDBNorm!=NULL)
{
delete[] pHistoDBNorm;
pHistoDBNorm=NULL;
}
}

but when i call this function in debug mode, i could read in a message box this following:

"User breakpoint called from code at 0x77f8629c"

and when i try to debug step by step (with F11 ) it calls this function:

void __cdecl operator delete(void* p)
{
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
_free_dbg(p, _NORMAL_BLOCK);
#else
free(p);

#endif
}

and the if condition is verified so i have the message box mentionned above

so if someone could explain me where is the problem?

thans in advance

jayjay

tell me if you need the whole code
 
try making it NULL before you delete and see if that works
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
I'm asking because I really don't know. Will asigning the pointer to NULL before deletion make it so that the original address of the variable jayjay wants to delete will be lost? i.e. Will this cause a memory leak?
 
Or will it assign the memory value it points to to NULL, then delete it (and if this is the case, why take time assigning it to NULL)?

Also, I was wondering if jayjay needs to assign the pointer to a block of memory the size of the original object it was pointing to, then assign it to NULL.

 
Hi jayjay

are you sure pHistoDBNorm is really a pointer to an array of some sort?

like this:

Object* p = new Object[n];

then delete [] p is appropriate.
Otherwise use
delete p (without the '[]` )

Greets, Tobi

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top