8f3f34c5ba91dae7dea4b9fb2a72dc63581f4e78
   1#include "cache.h"
   2#include "mru.h"
   3
   4void mru_append(struct mru *head, void *item)
   5{
   6        struct mru *cur = xmalloc(sizeof(*cur));
   7        cur->item = item;
   8        list_add_tail(&cur->list, &head->list);
   9}
  10
  11void mru_mark(struct mru *head, struct mru *entry)
  12{
  13        /* To mark means to put at the front of the list. */
  14        list_del(&entry->list);
  15        list_add(&entry->list, &head->list);
  16}
  17
  18void mru_clear(struct mru *head)
  19{
  20        struct list_head *pos;
  21        struct list_head *tmp;
  22
  23        list_for_each_safe(pos, tmp, &head->list) {
  24                free(list_entry(pos, struct mru, list));
  25        }
  26        INIT_LIST_HEAD(&head->list);
  27}