mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 18:19:43 +01:00
Free base tilesheet image after processing it
This isn't a memory leak (not even Valgrind complains), because it gets properly cleaned up in GraphicsResources::destroy(). Still, it's memory that is just laying around not being used, and in the name of deallocating things as soon as you no longer need them, we should deallocate the base tilesheet images after we split all of them into tiles. This reduces the memory cost of all tilesheet images by half, since we were essentially keeping around duplicates for nothing; this doesn't really have much of an impact with conventional tilesheet sizes, since they're usually small enough, but since 2.3 allowed for tilesheet images of any size, this is a pretty big deal for really big tilesheet images. It's okay to do this, even though they also get freed in GraphicsResources::destroy(), because SDL_FreeSurface() does a NULL check on the pointer passed to it, and we set the pointer to NULL after freeing the surfaces.
This commit is contained in:
parent
6077015fdc
commit
1f1b39a77a
1 changed files with 4 additions and 1 deletions
|
@ -341,7 +341,10 @@ void Graphics::updatetitlecolours()
|
||||||
\
|
\
|
||||||
extra_code \
|
extra_code \
|
||||||
} \
|
} \
|
||||||
}
|
} \
|
||||||
|
\
|
||||||
|
SDL_FreeSurface(grphx.im_##tilesheet); \
|
||||||
|
grphx.im_##tilesheet = NULL;
|
||||||
|
|
||||||
#define PROCESS_TILESHEET(tilesheet, tile_square, extra_code) \
|
#define PROCESS_TILESHEET(tilesheet, tile_square, extra_code) \
|
||||||
PROCESS_TILESHEET_RENAME(tilesheet, tilesheet, tile_square, extra_code)
|
PROCESS_TILESHEET_RENAME(tilesheet, tilesheet, tile_square, extra_code)
|
||||||
|
|
Loading…
Reference in a new issue