| * A simple most-recently-used cache, backed by a doubly-linked list. |
| * // Create a list. Zero-initialization is required. |
| * static struct mru cache; |
| * mru_append(&cache, item); |
| * // Iterate in MRU order. |
| * for (p = cache.head; p; p = p->next) { |
| * // Mark an item as used, moving it to the front of the list. |
| * // Reset the list to empty, cleaning up all resources. |
| * Note that you SHOULD NOT call mru_mark() and then continue traversing the |
| * list; it reorders the marked item to the front of the list, and therefore |
| * you will begin traversing the whole list again. |
| struct mru_entry *prev, *next; |
| struct mru_entry *head, *tail; |
| void mru_append(struct mru *mru, void *item); |
| void mru_mark(struct mru *mru, struct mru_entry *entry); |
| void mru_clear(struct mru *mru); |