Jump to content
  • Advertisement
Sign in to follow this  

new char ... heap error? [SOLVED]

This topic is 4397 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please help me work this out. VC++ 2005 Express is giving me the following runtime error at delete in the destructor of this class. "...This may be due to a corruption of the heap..." So I'm doing something wrong with this char array? In the Output window I'm getting... HEAP[NeHeGL.exe]: Heap block at 003782E8 modified at 00378333 past requested size of 43 Windows has triggered a breakpoint in NeHeGL.exe. So perhaps I've writen past the array?
...
unsigned char *Buffer;

cPacket(int Size)
{
	Buffer = new unsigned char[Size];
	for(int a=0;a<Size;a++)
		Buffer[a] = 'g';
}
~cPacket()
{
	delete [] Buffer;
}
...



Thanks DaveC [Edited by - bobason456 on May 7, 2006 7:37:58 AM]

Share this post


Link to post
Share on other sites
Advertisement
You have written outside the buffer somewhere (not shown in that code)
You can set a break point when the address change. Debug --> New Breakpoint --> New Data Breakpoint. Enter the address 0x00378333 and run

Share this post


Link to post
Share on other sites
Thanks… Yes I just found it. Added a line that broke an if statement without brackets yada yada. Was writing well past the end of the allocated memory space.

Thanks for your time though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!