diff options
author | tron <tron@openttd.org> | 2005-08-13 21:40:22 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-08-13 21:40:22 +0000 |
commit | 26d24f64fc78d15464e35aa56c7788dcf70eba39 (patch) | |
tree | 5a52ec88164269f211a4c7e969d6c65b3db7a425 | |
parent | bdd5d4ebb1c7934c01eab616f52bf8cb8076107b (diff) | |
download | openttd-26d24f64fc78d15464e35aa56c7788dcf70eba39.tar.xz |
(svn r2865) Push the responsibility for allocating the sprite heap into GfxInitSpriteMem()
-rw-r--r-- | spritecache.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/spritecache.c b/spritecache.c index e30a5e195..da1b7d43f 100644 --- a/spritecache.c +++ b/spritecache.c @@ -785,13 +785,13 @@ static void LoadSpriteTables(void) _compact_cache_counter = 0; } -static void GfxInitSpriteMem(void *ptr, uint32 size) +static void GfxInitSpriteMem(void) { // initialize sprite cache heap - _spritecache_ptr = ptr; + if (_spritecache_ptr == NULL) _spritecache_ptr = malloc(SPRITE_CACHE_SIZE); // A big free block - _spritecache_ptr->size = (size - sizeof(MemBlock)) | S_FREE_MASK; + _spritecache_ptr->size = (SPRITE_CACHE_SIZE - sizeof(MemBlock)) | S_FREE_MASK; // Sentinel block (identified by size == 0) NextBlock(_spritecache_ptr)->size = 0; @@ -801,8 +801,6 @@ static void GfxInitSpriteMem(void *ptr, uint32 size) void GfxLoadSprites(void) { - static byte *_sprite_mem; - // Need to reload the sprites only if the landscape changed if (_sprite_page_to_load != _opt.landscape) { _sprite_page_to_load = _opt.landscape; @@ -810,9 +808,7 @@ void GfxLoadSprites(void) // Sprite cache DEBUG(spritecache, 1) ("Loading sprite set %d.", _sprite_page_to_load); - // Reuse existing memory? - if (_sprite_mem == NULL) _sprite_mem = malloc(SPRITE_CACHE_SIZE); - GfxInitSpriteMem(_sprite_mem, SPRITE_CACHE_SIZE); + GfxInitSpriteMem(); LoadSpriteTables(); GfxInitPalettes(); } |