Mercurial > hg > openttd
changeset 4402:254c2ba8dac5 draft
(svn r6155) -Codechange: split Destroy routine from SpriteGroupPoolCleanBlock
Last change is to prepare for new pool system.
author | truelight <truelight@openttd.org> |
---|---|
date | Sat, 26 Aug 2006 19:47:13 +0000 |
parents | 3e07d834e228 |
children | 50936d5e527b |
files | newgrf_spritegroup.c |
diffstat | 1 files changed, 23 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf_spritegroup.c +++ b/newgrf_spritegroup.c @@ -16,37 +16,38 @@ static uint _spritegroup_count = 0; static MemoryPool _spritegroup_pool; +void DestroySpriteGroup(SpriteGroup *group) +{ + /* Free dynamically allocated memory */ + switch (group->type) { + case SGT_REAL: + free(group->g.real.loaded); + free(group->g.real.loading); + break; + + case SGT_DETERMINISTIC: + free(group->g.determ.adjusts); + free(group->g.determ.ranges); + break; + + case SGT_RANDOMIZED: + free(group->g.random.groups); + break; + + default: + break; + } +} static void SpriteGroupPoolCleanBlock(uint start_item, uint end_item) { uint i; for (i = start_item; i <= end_item; i++) { - SpriteGroup *group = (SpriteGroup*)GetItemFromPool(&_spritegroup_pool, i); - - /* Free dynamically allocated memory */ - switch (group->type) { - case SGT_REAL: - free(group->g.real.loaded); - free(group->g.real.loading); - break; - - case SGT_DETERMINISTIC: - free(group->g.determ.adjusts); - free(group->g.determ.ranges); - break; - - case SGT_RANDOMIZED: - free(group->g.random.groups); - break; - - default: - break; - } + DestroySpriteGroup((SpriteGroup*)GetItemFromPool(&_spritegroup_pool, i)); } } - /* Initialize the SpriteGroup pool */ static MemoryPool _spritegroup_pool = { "SpriteGr", SPRITEGROUP_POOL_MAX_BLOCKS, SPRITEGROUP_POOL_BLOCK_SIZE_BITS, sizeof(SpriteGroup), NULL, &SpriteGroupPoolCleanBlock, 0, 0, NULL };