/* * free up a list and all the nodes in it --- but *not* whatever the nodes * might point to! */ void DLFreeList(Dllist *list) { Dlelem *curr; while ((curr = DLRemHead(list)) != NULL) pfree(curr); pfree(list); }
/* free up a list and all the nodes in it*/ void DLFreeList(Dllist* l) { Dlelem* curr; while ( (curr = DLRemHead(l)) != 0) free(curr); free(l); }
void DLRemove(Dlelem* e) { Dllist* l; if (e->dle_prev) e->dle_prev->dle_next = e->dle_next; if (e->dle_next) e->dle_next->dle_prev = e->dle_prev; /* check to see if we're removing the head or tail */ l = e->dle_list; if (e == l->dll_head) DLRemHead(l); if (e == l->dll_tail) DLRemTail(l); }
/* * Releases/Surrenders all entries held by this client * * During normal functionality, client should release all the owned entries * and this is a no-op. In case of a client error, this callback makes sure all * entries are returned to the cache. * * This function operates on client data and does not need to be synchronized. */ void Cache_SurrenderClientEntries(Cache *cache) { Assert(NULL != cache); uint32 nAcquiredEntries = 0; uint32 nCachedEntries = 0; Dlelem *elt = NULL; /* Surrender all owned entries */ while (NULL != (elt = DLRemHead(cache->ownedEntries))) { CacheEntry *entry = DLE_VAL(elt); switch(entry->state) { case CACHE_ENTRY_ACQUIRED: Cache_ReleaseAcquired(cache, entry, false /* unregisterCleanup */); nAcquiredEntries++; break; case CACHE_ENTRY_CACHED: case CACHE_ENTRY_DELETED: Cache_ReleaseCached(cache, entry, false /* unregisterCleanup */); nCachedEntries++; break; default: Assert(false && "unexpected cache entry state"); } /* Free linked list element */ DLFreeElem(elt); } if (nAcquiredEntries > 0 || nCachedEntries > 0) { elog(gp_workfile_caching_loglevel, "Cleanup released %u acquired and %u cached entries from client", nAcquiredEntries, nCachedEntries); } }