struct QSort
{
sID ID;
double SimilarityValue;
};
// sID is also another little struct
struct sID
{
int m_ClassID;
int m_ModelID;
};
Strange error in allocation with new operator
Hi,
I have a little struct QSort
and in a function I allocate memory with the command:
QSort *Similarities = new QSort[Database.m_NumModels];
The program stops in this command and the problem is that (when debugging) it throws the following message:
User breakpoint called from code at 0x77f6f570
It then shows the dissasembly window and when I proceed step by step, it requires the path for DBGHOOK.C which I cannot find anywhere.
If I run the program it throws an unhandled exception in DBGHEAP.C at this point
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
Database.m_NumModels is an integer which I have ensured while debugging that has the right value.
Does anybody know any possible reason for this to happen? I cannot think anything, everything seems to me correct.
Thanks for any help!
My guess is that something you've done before this point, but very recently before it, most likely, has corrupted the heap in some way or another. Check the code that runs before this line carefully. Look for deletes that might be deleting improper pointers, check for writing beyond the bounds of memory, make sure that you use delete [] when deleting arrays, etc.
Ok, that seems realy strange and I am not shure, but I would try a constant instead of Database.m_NumModels.
If that works, then Database is perhaps not instanciated when refering to Database.m_NumModels.
Check all your Pointers if they are refering to an instanciated object when needed, because _ASSERTE(_CrtIsValidHeapPointer(pUserData));
seems to have a problem with pUserData (because _CrtIsValidHeapPointer() retruns false).
You will find it sooner or later, good luck :)
-Constantin
If that works, then Database is perhaps not instanciated when refering to Database.m_NumModels.
Check all your Pointers if they are refering to an instanciated object when needed, because _ASSERTE(_CrtIsValidHeapPointer(pUserData));
seems to have a problem with pUserData (because _CrtIsValidHeapPointer() retruns false).
You will find it sooner or later, good luck :)
-Constantin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement