summaryrefslogtreecommitdiff
path: root/src/caches/dcache_free.c
blob: 1ba80414dbbe677976f134f4b7f5759e15ea3e9e (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 <s6-dns/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 ;
}