diff options
author | truelight <truelight@openttd.org> | 2006-08-26 19:47:13 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2006-08-26 19:47:13 +0000 |
commit | 55ab975c368118b8db667f97959ee60778961397 (patch) | |
tree | efb0ba0ecc4fc6890ad3429af704c7cfccd6c33d | |
parent | 5d3ed62e468fac9529fd15a7adf047ee252d0ac6 (diff) | |
download | openttd-55ab975c368118b8db667f97959ee60778961397.tar.xz |
(svn r6155) -Codechange: split Destroy routine from SpriteGroupPoolCleanBlock
Last change is to prepare for new pool system.
-rw-r--r-- | newgrf_spritegroup.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/newgrf_spritegroup.c b/newgrf_spritegroup.c index 591a1f736..57372f51b 100644 --- a/newgrf_spritegroup.c +++ b/newgrf_spritegroup.c @@ -16,37 +16,38 @@ enum { 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 }; |