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

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

#include <s6-dns/dcache.h>

static dcache_t const dcache_zero = DCACHE_ZERO ;

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

void dcache_free (dcache_t *z)
{
  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 ;
}