+ fprintf_filtered (file, _("Deprecated remotecache flag is %s.\n"), value);
+}
+
+/* Add BLOCK to circular block list BLIST, behind the block at *BLIST.
+ *BLIST is not updated (unless it was previously NULL of course).
+ This is for the least-recently-allocated list's sake:
+ BLIST points to the oldest block.
+ ??? This makes for poor cache usage of the free list,
+ but is it measurable? */
+
+static void
+append_block (struct dcache_block **blist, struct dcache_block *block)
+{
+ if (*blist)
+ {
+ block->next = *blist;
+ block->prev = (*blist)->prev;
+ block->prev->next = block;
+ (*blist)->prev = block;
+ /* We don't update *BLIST here to maintain the invariant that for the
+ least-recently-allocated list *BLIST points to the oldest block. */
+ }
+ else
+ {
+ block->next = block;
+ block->prev = block;
+ *blist = block;
+ }
+}
+
+/* Remove BLOCK from circular block list BLIST. */
+
+static void
+remove_block (struct dcache_block **blist, struct dcache_block *block)
+{
+ if (block->next == block)
+ {
+ *blist = NULL;
+ }
+ else
+ {
+ block->next->prev = block->prev;
+ block->prev->next = block->next;
+ /* If we removed the block *BLIST points to, shift it to the next block
+ to maintain the invariant that for the least-recently-allocated list
+ *BLIST points to the oldest block. */
+ if (*blist == block)
+ *blist = block->next;
+ }
+}
+
+/* Iterate over all elements in BLIST, calling FUNC.
+ PARAM is passed to FUNC.
+ FUNC may remove the block it's passed, but only that block. */
+
+static void
+for_each_block (struct dcache_block **blist, block_func *func, void *param)
+{
+ struct dcache_block *db;
+
+ if (*blist == NULL)
+ return;
+
+ db = *blist;
+ do
+ {
+ struct dcache_block *next = db->next;
+
+ func (db, param);
+ db = next;
+ }
+ while (*blist && db != *blist);
+}
+
+/* BLOCK_FUNC routine for dcache_free. */
+
+static void
+free_block (struct dcache_block *block, void *param)
+{
+ xfree (block);
+}
+
+/* Free a data cache. */
+
+void
+dcache_free (DCACHE *dcache)
+{
+ splay_tree_delete (dcache->tree);
+ for_each_block (&dcache->oldest, free_block, NULL);
+ for_each_block (&dcache->freelist, free_block, NULL);
+ xfree (dcache);