Hey thanks guys. I am trying valgrind now.
I also fixed the broken link on my code. IS it possible to have pointers to structs within pointers to structs within pointers to structs etc???
I am trying to do this which has a compile error.
Code:
//gr->mtiles[y][x]->rcTiles.w = gr->tilew;
//gr->mtiles[y][x]->rcTiles.h = gr->tileh;
gr is a pointer to struct GameRes
inside gr is mtiles, a pointer to struct Tile
inside Tile is rcTiles a pointer to struct SDL_Rect (which as members w and h)
mtiles is an array created with malloc like so:
Code:
gr->mtiles = (Tile **) malloc(sizeof(Tile *)); //malloc new Tile struct
for(i = 0; i < MAPSIZE; i++) //malloc new Tile sturct
{
gr->mtiles[i] = (Tile *) malloc(MAPSIZE * sizeof(Tile));
gr->mtiles[i]->rcTiles = (SDL_Rect *) malloc(sizeof(SDL_Rect));
}
Is this just too complicated? Am I making too much work for miself?