summaryrefslogtreecommitdiff
path: root/src/cache/dcache_free.c
blob: 16c074e1e3910e83d086d0282fa4d4f1a38c2123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ISC license. */

#include <skalibs/alloc.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/avltree.h>

#include <shibari/dcache.h>

static void dcache_node_free (void *p)
{
  alloc_free(((dcache_node_t *)p)->key.s) ;
}

void dcache_free (dcache_t *z)
{
  static dcache_t const dcache_zero = DCACHE_ZERO ;
  avltree_free(&z->by_expire) ;
  avltree_free(&z->by_entry) ;
  avltree_free(&z->by_key) ;
  gensetdyn_deepfree(&z->storage, &dcache_node_free) ;
  *z = dcache_zero ;
}