Weird SDL problem. - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Weird SDL problem. (/thread-6536.html)
Weird SDL problem. - Skorche - Jan 19, 2004 03:29 AM
So I'm programming along, and all of a sudden, some of my data structures are getting corrupted. So I run it step by step in the debugger to find where things are going awry. I finally tracked it down to a call to SDL_PollEvent().
It doesn't scramble it, or crash the program, just writes the same corrupt data in each time. Any possible ideas of what this might be? I can't possibly be getting overlaping memory sections between restarts and everything eles, can I?
I'd post source code, but I don't know where to start. The functions are completely unrelated. I'm even still using the example SDL event handling and initialization code.
Weird SDL problem. - OneSadCookie - Jan 19, 2004 04:26 AM
The obvious thing to check is that the pointer you pass to SDL_PollEvent really is valid.
Yes, if nothing random has happened, memory will usually be allocated in exactly the same place each run.
Weird SDL problem. - IBethune - Jan 19, 2004 07:04 AM
As well as what OSC already said, I found that most of my memory trashing errors were related to accidentally releasing CoreFoundation variables that I had no right to release! Try commenting out all irrelevant code before the SDL_PollEvent call, and see when it stops breaking!!
Weird SDL problem. - Skorche - Jan 19, 2004 12:51 PM
Well it works somewhat like this:
I've got some arrays with vertices and associated properties for a physics system. Specific elements of the arrays keep getting changed when I call SDL_PollEvents.
My function that handles events has a static variable defined in it, I just pass the address of that.
IBethune: My physics code has no dependencies outside of the standard C libraries, and everything else is SDL code. Most of that is still untouched from the template. I'm not quite sure what else I can disable and still have it work. Very frustrating when your code is only a hundred lines long, and you still have problems.