a "user breakpoint..." message i don't understand
-
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 gerald tell me if you need the whole code
-
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 gerald tell me if you need the whole code
The "user breakpoint" message usually shows up when something very wrong has happened. Chances are you are trying to delete a pointer that is junk. (Quick question, are you *sure* the pointer is ether NULL or pointing to a valid, deletable block of memory that was allocated using new [] ??) Even a broken clock is right twice a day.
-
The "user breakpoint" message usually shows up when something very wrong has happened. Chances are you are trying to delete a pointer that is junk. (Quick question, are you *sure* the pointer is ether NULL or pointing to a valid, deletable block of memory that was allocated using new [] ??) Even a broken clock is right twice a day.
when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald
-
when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald
What is pHistoDBNorm initialized to? (i.e. in the constructor). If you don't initialize it to NULL in the constructor, then the first time you call AllocHistoNorm, then it will try to delete trash. Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
What is pHistoDBNorm initialized to? (i.e. in the constructor). If you don't initialize it to NULL in the constructor, then the first time you call AllocHistoNorm, then it will try to delete trash. Tim Smith I'm going to patent thought. I have yet to see any prior art.
I initialize to NULL in the constructor, the problem arrive when i don't want to use pHistoDBNorm anymore i want to delete memory, and it doesn't work!!!
-
I initialize to NULL in the constructor, the problem arrive when i don't want to use pHistoDBNorm anymore i want to delete memory, and it doesn't work!!!
As your deleting an array, you may find that you have written beyond the range of allocated memory such as: char *p = new char[100]; p[-1] = '\0' ; // error p[100] = 'H'; // error This can cause breakpoints when deallocating the memory, as in debug mode special buffers are placed before and after you allocated data to check for this kind of thing. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
-
when you tell me about "deletable block of memory that was allocated", what do you mean about "deletable", because you could see in the following code how i allocate memory for this pointer: void LoadHistoDB::AllocHistoNorm(long NumHisto) { DeleteHistoNorm(); pHistoDBNorm=new double[NumHisto]; } do you think when you see the delete function that there is a problem? thanks gerald
When you call DeleteHistoNorm() you check to see if pHistoDBNorm is NULL or not. The thing is that when you declare double *pHistoDBNorm, just to be safe in your class constructor you should set pHistoDBNorm = NULL. I don't know if you are using this pointer somewhere else in your source code without initializing it and then all of a sudden you try to delete it. none