Original Post
For three days this has had me stumped. My game was running fine (nearly complete) until I recompiled after adding some sound effects. Now I have a page fault with previously working code. Here we go:
I have a char** variable called "grid". It is allocated based on a variable called "difficulty". I know the problem lies not in the allocation or deallocation code, because it worked fine before.
The problem is, if I allocate grid as a 4x4 or 6x6 array, I get the page fault. Debugging shows it comes when I call free (I''m using straight C in VC++ 6, BTW) on the last 1x4 or 1x6 element in the array. Debugging gives me something like:
Debug Error: DAMAGE: after Normal block (#58) at
That''s with the 4x4. With the 6x6 it''s #60 instead of #58.
Now, if I allocate an 8x8 array, no problem. Everything works like it should. I consulted MSDN and couldn''t find anything specific, but I''m assuming after reading about _free_dbg and the debuggers mempory management, that I''m somehow writing past the upper bounds of the allocated memory.
But that leaves me with several questions. The code is the same no matter what the array size, so why doesn''t it do the same for an 8x8 array? Also, I changed nothing in the original code when I added the sound effects. I just added some code to load and play a few waves via my library. So why did this suddenly crap out when I recompiled?
I thought I could squash any bug with a day or two away from a project, but this one has me beat. Any ideas, clues or suggestions are greatly appreciated. This is my puzzle contest project. I had planned to finish by Sunday and move on to something else, but so much for that.