[Help] Bad Ptr in VC debugger
Hello I've been debugging a application i wrote and i've come to a situation.
I've got a some code that im freeing inside a destructor.
so say now i create another constructor and destructor in another .cpp
any suggestions to why it should show bad ptr in the vc debugger even tho it doesnt crash or give me errors.
Only thing i can think of is that im not freeing the memory inside the local decontructor to show the vc debugger that im freeing it...
any suggestions in how something like this happens or a fix....
Sorry if this sounds confusing....
I've got a some code that im freeing inside a destructor.
Code:
struct Memory
{
public:
/* constructor and destructor */
CData( )
{
}
CData( unsigned short datasize, bool readata = true )
{
if( readata ) EncBuffer = (unsigned char*)malloc( datasize );
else Buffer = (unsigned char*)malloc( datasize );
}
~CData( )
{
// free all my data here....
delete[] Buffer;
delete[] EncBuffer;
Buffer = NULL;
EncBuffer = NULL;
}
Code:
// ofc calling my header to link Memory....
CBaseaddy::CBaseaddy()
{
}
CBaseaddy::~CBaseaddy()
{
}
void CBaseaddy::StartEngine()
{
Memory checking;
checking->Buffer; // do whatever here
}
Only thing i can think of is that im not freeing the memory inside the local decontructor to show the vc debugger that im freeing it...
any suggestions in how something like this happens or a fix....
Sorry if this sounds confusing....

.