src/spritecache.cpp
changeset 8040 92c69fcd0d61
parent 8037 8aa4ace04383
child 8113 31b7784db761
equal deleted inserted replaced
8039:fa18f4352154 8040:92c69fcd0d61
    51 
    51 
    52 		DEBUG(sprite, 4, "Increasing sprite cache to %d items (%d bytes)", items, items * sizeof(*_spritecache));
    52 		DEBUG(sprite, 4, "Increasing sprite cache to %d items (%d bytes)", items, items * sizeof(*_spritecache));
    53 
    53 
    54 		_spritecache = ReallocT(_spritecache, items);
    54 		_spritecache = ReallocT(_spritecache, items);
    55 
    55 
    56 		if (_spritecache == NULL) {
       
    57 			error("Unable to allocate sprite cache of %d items (%d bytes)", items, items * sizeof(*_spritecache));
       
    58 		}
       
    59 
       
    60 		/* Reset the new items and update the count */
    56 		/* Reset the new items and update the count */
    61 		memset(_spritecache + _spritecache_items, 0, (items - _spritecache_items) * sizeof(*_spritecache));
    57 		memset(_spritecache + _spritecache_items, 0, (items - _spritecache_items) * sizeof(*_spritecache));
    62 		_spritecache_items = items;
    58 		_spritecache_items = items;
    63 	}
    59 	}
    64 
    60 
   409 		}
   405 		}
   410 	}
   406 	}
   411 
   407 
   412 	/* Display an error message and die, in case we found no sprite at all.
   408 	/* Display an error message and die, in case we found no sprite at all.
   413 	 * This shouldn't really happen, unless all sprites are locked. */
   409 	 * This shouldn't really happen, unless all sprites are locked. */
   414 	if (best == (uint)-1)
   410 	if (best == (uint)-1) error("Out of sprite memory");
   415 		error("Out of sprite memory");
       
   416 
   411 
   417 	/* Mark the block as free (the block must be in use) */
   412 	/* Mark the block as free (the block must be in use) */
   418 	s = (MemBlock*)GetSpriteCache(best)->ptr - 1;
   413 	s = (MemBlock*)GetSpriteCache(best)->ptr - 1;
   419 	assert(!(s->size & S_FREE_MASK));
   414 	assert(!(s->size & S_FREE_MASK));
   420 	s->size |= S_FREE_MASK;
   415 	s->size |= S_FREE_MASK;