I do:
typedef struct {
Scene *scene;
MeshStore *store;
float angle;
} DebugModel
...
free_entire_store(debug_model.store);
/* Frees the store and any meshes related to it */
void free_entire_store(MeshStore *store) {
/* implementation not important for the problem at hand */
}
Now, if I gdb this putting a breakpoint at the beginning of free_entire_store
I get the following strange data..
(gdb) p debug_model
$5 = {scene = 0x1044a680, store = 0x1044a630, angle = 87.8401108}
(gdb) p store
$6 = (MeshStore *) 0x10438b40
debug_model is a global, the above debugging output is from the same point int he program.
So, even though I simply pass the pointer as a parameter, it somehow gets changed. The stack is corrupted, albeit in a very predictable manner (the same data appears every run). What could have caused this? I don't think I freed anythign twice or something before calling this function. How can the value passed as parameter not correspond with the value in the stack?