summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-26 19:47:13 +0000
committertruelight <truelight@openttd.org>2006-08-26 19:47:13 +0000
commitb3cf0189a3163781fb661e9b1431b5c381d18c80 (patch)
treeefb0ba0ecc4fc6890ad3429af704c7cfccd6c33d
parent5d991a87d498a9f088e9fa2d56e8b5911d6e0147 (diff)
downloadopenttd-b3cf0189a3163781fb661e9b1431b5c381d18c80.tar.xz
(svn r6155) -Codechange: split Destroy routine from SpriteGroupPoolCleanBlock
Last change is to prepare for new pool system.
-rw-r--r--newgrf_spritegroup.c45
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 };