summaryrefslogtreecommitdiff
path: root/src/caches/dcache_free.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-11-25 13:03:37 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-11-25 13:03:37 +0000
commitd4350788eea01f04b464d382d74ee0f391a78398 (patch)
tree908e24ce99ea465b9cd05ea15d61b702c1b883cb /src/caches/dcache_free.c
parent922841847862b39662b1039304de1361401f214b (diff)
downloads6-dns-d4350788eea01f04b464d382d74ee0f391a78398.tar.xz
Initial libdcache implementation
Diffstat (limited to 'src/caches/dcache_free.c')
-rw-r--r--src/caches/dcache_free.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/caches/dcache_free.c b/src/caches/dcache_free.c
new file mode 100644
index 0000000..7937332
--- /dev/null
+++ b/src/caches/dcache_free.c
@@ -0,0 +1,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 ;
+}