/* * CatCacheRemoveCList * * Unlink and delete the given cache list entry * * NB: any dead member entries that become unreferenced are deleted too. */ static void CatCacheRemoveCList(CatCache *cache, CatCList *cl) { int i; Assert(cl->refcount == 0); Assert(cl->my_cache == cache); /* delink from member tuples */ for (i = cl->n_members; --i >= 0;) { CatCTup *ct = cl->members[i]; Assert(ct->c_list == cl); ct->c_list = NULL; /* if the member is dead and now has no references, remove it */ if ( #ifndef CATCACHE_FORCE_RELEASE ct->dead && #endif ct->refcount == 0) CatCacheRemoveCTup(cache, ct); } /* delink from linked list */ DLRemove(&cl->cache_elem); /* free associated tuple data */ if (cl->tuple.t_data != NULL) pfree(cl->tuple.t_data); pfree(cl); }
/* * CatCacheRemoveCList * * Unlink and delete the given cache list entry */ static void CatCacheRemoveCList(CatCache *cache, CatCList *cl) { int i; Assert(cl->refcount == 0); Assert(cl->my_cache == cache); /* delink from member tuples */ for (i = cl->n_members; --i >= 0;) { CatCTup *ct = cl->members[i]; Assert(ct->c_list == cl); ct->c_list = NULL; } /* delink from linked list */ DLRemove(&cl->cache_elem); /* free associated tuple data */ if (cl->tuple.t_data != NULL) pfree(cl->tuple.t_data); pfree(cl); }
/* * CatCacheRemoveCTup * * Unlink and delete the given cache entry * * NB: if it is a member of a CatCList, the CatCList is deleted too. * Both the cache entry and the list had better have zero refcount. */ static void CatCacheRemoveCTup(CatCache *cache, CatCTup *ct) { Assert(ct->refcount == 0); Assert(ct->my_cache == cache); if (ct->c_list) { /* * The cleanest way to handle this is to call CatCacheRemoveCList, * which will recurse back to me, and the recursive call will do the * work. Set the "dead" flag to make sure it does recurse. */ ct->dead = true; CatCacheRemoveCList(cache, ct->c_list); return; /* nothing left to do */ } /* delink from linked list */ DLRemove(&ct->cache_elem); /* free associated tuple data */ if (ct->tuple.t_data != NULL) pfree(ct->tuple.t_data); pfree(ct); --cache->cc_ntup; --CacheHdr->ch_ntup; }
void PyrGC::BecomePermanent(PyrObject *inObject) { if (IsGrey(inObject)) mNumGrey--; DLRemove(inObject); inObject->gc_color = obj_permanent; inObject->obj_flags |= obj_immutable; inObject->next = inObject->prev = inObject; }
/* * CatCacheRemoveCTup * * Unlink and delete the given cache entry * * NB: if it is a member of a CatCList, the CatCList is deleted too. */ static void CatCacheRemoveCTup(CatCache *cache, CatCTup *ct) { Assert(ct->refcount == 0); Assert(ct->my_cache == cache); if (ct->c_list) CatCacheRemoveCList(cache, ct->c_list); /* delink from linked lists */ DLRemove(&ct->lrulist_elem); DLRemove(&ct->cache_elem); /* free associated tuple data */ if (ct->tuple.t_data != NULL) pfree(ct->tuple.t_data); pfree(ct); --cache->cc_ntup; --CacheHdr->ch_ntup; }
void PyrGC::ToGrey2(PyrObjectHdr* obj) { /* move obj from white to grey */ /* link around object */ DLRemove(obj); /* link in new place */ DLInsertAfter(&mGrey, obj); /* set grey list pointer to obj */ obj->gc_color = mGreyColor; mNumGrey ++ ; }
/* * Unregister entry from cleanup list of the cache * */ static void Cache_UnregisterCleanup(Cache *cache, CacheEntry *entry) { Assert(NULL != cache); Assert(NULL != entry); Dlelem *crtElem = DLGetHead(cache->ownedEntries); while (NULL != crtElem && DLE_VAL(crtElem) != entry) { crtElem = DLGetSucc(crtElem); } Assert(NULL != crtElem && "could not locate element"); /* Found matching element. Remove and free. Note that entry is untouched */ DLRemove(crtElem); DLFreeElem(crtElem); }
/* remove invalid notifies before returning */ void PQcleanNotify() { Dlelem *e, *next; PQNotifyList *p; e = DLGetHead(pqNotifyList); while (e) { next = DLGetSucc(e); p = (PQNotifyList*)DLE_VAL(e); if (p->valid == 0) { DLRemove(e); DLFreeElem(e); pfree(p); } e = next; } }