engine/zone.c
/*	Frees the memory and removes it from the LRU list
*/
Frees the memory and removes it from the LRU list
Frees the memory and removes it from the LRU list
void Cache_Free(cache_user_t *c,bool freetextures) 
{
	cache_system_t	*cs;
	if (!c->data)
		Sys_Error ("Cache_Free: not allocated");
	cs = ((cache_system_t *)c->data) - 1;
	if(!cs)
	{
		Sys_Error("Failed to reference pointer, this shouldn't happen!\n");
		return;
	}
	cs->prev->next = cs->next;
	cs->next->prev = cs->prev;
	cs->next = cs->prev = NULL;
	c->data = NULL;
	Cache_UnlinkLRU (cs);
	if (freetextures)
		TexMgr_FreeTexturesForOwner ((model_t *)(c + 1) - 1);
}
void Cache_Free ( cache_user_t * c , bool freetextures ) { cache_system_t * cs ; if ( ! c -> data ) Sys_Error ( " " ) ; cs = ( ( cache_system_t * ) c -> data ) - 1 ; if ( ! cs ) { Sys_Error ( " \n " ) ; return ; } cs -> prev -> next = cs -> next ; cs -> next -> prev = cs -> prev ; cs -> next = cs -> prev = NULL ; c -> data = NULL ; Cache_UnlinkLRU ( cs ) ; if ( freetextures ) TexMgr_FreeTexturesForOwner ( ( model_t * ) ( c + 1 ) - 1 ) ; }
Frees the memory and removes it from the LRU list
Frees the memory and removes it from the LRU list
//johnfitz -- added second argument //johnfitz -- if a model becomes uncached, free the gltextures.  This only works //becuase the cache_user_t is the last component of the model_t struct.  Should //fail harmlessly if *c is actually part of an sfx_t struct.  I FEEL DIRTY