summaryrefslogtreecommitdiff
path: root/src/libdcache/dcache_free.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libdcache/dcache_free.c')
-rw-r--r--src/libdcache/dcache_free.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libdcache/dcache_free.c b/src/libdcache/dcache_free.c
new file mode 100644
index 0000000..16c074e
--- /dev/null
+++ b/src/libdcache/dcache_free.c
@@ -0,0 +1,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 ;
+}