/* ============== Cache_Check ============== */ void *Cache_Check (cache_user_t *c) { cache_system_t *cs; if (!c->data) return NULL; cs = ((cache_system_t *)c->data) - 1; // move to head of LRU Cache_UnlinkLRU (cs); Cache_MakeLRU (cs); return c->data; }
/* * ============== * Cache_Check * ============== */ void * Cache_Check(const cache_user_t *c) { cache_system_t *cs; if (!c->data) return NULL; cs = Cache_System(c); /* move to head of LRU */ Cache_UnlinkLRU(cs); Cache_MakeLRU(cs); return c->data; }
/* ============== Cache_Free Frees the memory and removes it from the LRU list ============== */ void Cache_Free (cache_user_t *c) { cache_system_t *cs; if (!c->data) Sys_Error ("Cache_Free: not allocated"); cs = ((cache_system_t *)c->data) - 1; cs->prev->next = cs->next; cs->next->prev = cs->prev; cs->next = cs->prev = NULL; c->data = NULL; Cache_UnlinkLRU (cs); }
/* * ============== * Cache_Free * * Frees the memory and removes it from the LRU list * ============== */ void Cache_Free(cache_user_t *c) { cache_system_t *cs; if (!c->data) Sys_Error("%s: not allocated", __func__); cs = Cache_System(c); cs->prev->next = cs->next; cs->next->prev = cs->prev; cs->next = cs->prev = NULL; c->pad = 0; c->data = NULL; Cache_UnlinkLRU(cs); }
/* ============== Cache_Free Frees the memory and removes it from the LRU list ============== */ void Cache_Free (cache_user_t *c, qboolean freetextures) //johnfitz -- added second argument { cache_system_t *cs; if (!c->data) Sys_Error ("Cache_Free: not allocated"); cs = ((cache_system_t *)c->data) - 1; cs->prev->next = cs->next; cs->next->prev = cs->prev; cs->next = cs->prev = NULL; c->data = NULL; Cache_UnlinkLRU (cs); //johnfitz -- if a model becomes uncached, free the gltextures. This only works //becuase the cache_user_t is the last component of the qmodel_t struct. Should //fail harmlessly if *c is actually part of an sfx_t struct. I FEEL DIRTY if (freetextures) TexMgr_FreeTexturesForOwner ((qmodel_t *)(c + 1) - 1); }