spritecache.c
changeset 2339 1c64119d5a3b
parent 2329 f68428464540
child 2340 0a9f3eeccb96
--- a/spritecache.c	Sat Aug 13 21:35:31 2005 +0000
+++ b/spritecache.c	Sat Aug 13 21:40:22 2005 +0000
@@ -785,13 +785,13 @@
 	_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 @@
 
 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 @@
 		// 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();
 	}