Re: Another debugger question
On Apr 4, 9:54 am, "Daniel T." <danie...@earthlink.net> wrote:
JoeC <enki...@yahoo.com> wrote:
What does this mean and how can I use it to track down a bug?
The below is the operator delete function. If one if its asserts is
firing, probably either you are trying to delete something that wasn't
newed, or you are trying to delete something twice.
*void operator delete() - delete a block in the debug heap
*
*Purpose:
* Deletes any type of block.
*
*Entry:
* void *pUserData - pointer to a (user portion) of memory b=
lock
in the
* debug heap
*
*Return:
* <void>
*
*dbgnew.cpp - defines C++ scalar delete routine, debug version
void operator delete(
void *pUserData
)
{
_CrtMemBlockHeader * pHead;
RTCCALLBACK(_RTC_Free_hook, (pUserData, 0));
if (pUserData == NULL)
return;
_mlock(_HEAP_LOCK); /* block other threads */
__TRY
/* get a pointer to memory block header */
pHead = pHdr(pUserData);
/* verify block type */
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)=
);
_free_dbg( pUserData, pHead->nBlockUse );
__FINALLY
_munlock(_HEAP_LOCK); /* release other threa=
ds */
__END_TRY_FINALLY
return;
}
#endif /* _DEBUG */
Thanks, I figured that out when I commented out the delete. I am
trying to learn how to use the debugger. I don't delete the array any
where but in the delete. I am wondering if the program is doing
something where it is messing with my array when it runs. I only read
data and change the values of the array elements.
I did get this in my array pointer with the debugger:
BYTE * bits; CXX0034: Error: types incompatible with operator
I don't know where my array can be deleted. I create the array in the
constructor then I modify colors then I display the graphic.
Constructor:
bits = new BYTE[acc*dwn];
for(int lp =0; lp != (acc*dwn); lp++)
bits[lp]=0;
Then I set the colors to 0:
for(int lp =0; lp != 16; lp++){
bInfo.bmiColors[lp].rgbBlue = 0;
bInfo.bmiColors[lp].rgbGreen = 0;
bInfo.bmiColors[lp].rgbRed = 0;
bInfo.bmiColors[lp].rgbReserved = 0;
}
colors[1].setColor(255,0,255);
colors[2].setColor(0,255,255);
colors[3].setColor(255,255,0);
for(int lp = 0; lp != 3; lp++){
b.setColor(lp,colors[lp].r(),colors[lp].g(),colors[lp].b());
}
Code:
void bitmap::setColor(int n, BYTE r, BYTE g, BYTE b){
bInfo.bmiColors[n].rgbBlue = b;
bInfo.bmiColors[n].rgbGreen = g;
bInfo.bmiColors[n].rgbRed = r;
bInfo.bmiColors[n].rgbReserved = 0;
}
The only other thing I can think of is that I declare the bitmap in
main:
bitmap b;
then I access them as globals and externs:
extern bitmap b;