diff options
author | tron <tron@openttd.org> | 2006-10-28 10:55:26 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-10-28 10:55:26 +0000 |
commit | ef862a2973c0aa13932edc5d446ed04f7ad110c9 (patch) | |
tree | c190bc499a6265878b03864d2de0d32f2d0048ca | |
parent | 41e34a1c1657fd39692c876235dab877a6c62d18 (diff) | |
download | openttd-ef862a2973c0aa13932edc5d446ed04f7ad110c9.tar.xz |
(svn r6974) use the pool macros for the SpriteGroup pool
-rw-r--r-- | newgrf_spritegroup.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/newgrf_spritegroup.c b/newgrf_spritegroup.c index 5ae33f4cb..1935dd4ea 100644 --- a/newgrf_spritegroup.c +++ b/newgrf_spritegroup.c @@ -8,13 +8,10 @@ #include "newgrf_spritegroup.h" #include "date.h" -enum { - SPRITEGROUP_POOL_BLOCK_SIZE_BITS = 4, /* (1 << 4) == 16 items */ - SPRITEGROUP_POOL_MAX_BLOCKS = 8000, -}; +static void SpriteGroupPoolCleanBlock(uint start_item, uint end_item); static uint _spritegroup_count = 0; -static MemoryPool _spritegroup_pool; +STATIC_POOL(SpriteGroup, SpriteGroup, 4, 8000, NULL, SpriteGroupPoolCleanBlock); void DestroySpriteGroup(SpriteGroup *group) { @@ -45,29 +42,26 @@ static void SpriteGroupPoolCleanBlock(uint start_item, uint end_item) uint i; for (i = start_item; i <= end_item; i++) { - DestroySpriteGroup((SpriteGroup*)GetItemFromPool(&_spritegroup_pool, i)); + DestroySpriteGroup(GetSpriteGroup(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 }; - /* Allocate a new SpriteGroup */ SpriteGroup *AllocateSpriteGroup(void) { /* This is totally different to the other pool allocators, as we never remove an item from the pool. */ - if (_spritegroup_count == _spritegroup_pool.total_items) { - if (!AddBlockToPool(&_spritegroup_pool)) return NULL; + if (_spritegroup_count == GetSpriteGroupPoolSize()) { + if (!AddBlockToPool(&_SpriteGroup_pool)) return NULL; } - return (SpriteGroup*)GetItemFromPool(&_spritegroup_pool, _spritegroup_count++); + return GetSpriteGroup(_spritegroup_count++); } void InitializeSpriteGroupPool(void) { - CleanPool(&_spritegroup_pool); + CleanPool(&_SpriteGroup_pool); _spritegroup_count = 0; } |