summaryrefslogtreecommitdiff
path: root/src/libdatastruct
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-04-13 02:19:08 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-04-13 02:19:08 +0000
commit57459439db1f48dbbace1ab059117798fa26d203 (patch)
tree537c15504b977b30af126ff4f9425c690672dc93 /src/libdatastruct
parent564c6ba2f899a4b530d58f6ac123e31d6b797fe2 (diff)
downloadskalibs-57459439db1f48dbbace1ab059117798fa26d203.tar.xz
Add genset[dyn]_deepfree
Diffstat (limited to 'src/libdatastruct')
-rw-r--r--src/libdatastruct/genset_deepfree.c16
-rw-r--r--src/libdatastruct/gensetdyn_deepfree.c17
2 files changed, 33 insertions, 0 deletions
diff --git a/src/libdatastruct/genset_deepfree.c b/src/libdatastruct/genset_deepfree.c
new file mode 100644
index 0000000..e219344
--- /dev/null
+++ b/src/libdatastruct/genset_deepfree.c
@@ -0,0 +1,16 @@
+/* ISC license. */
+
+#include <skalibs/functypes.h>
+#include <skalibs/genset.h>
+
+static int freeiter (char *s, void *aux)
+{
+ freefunc_t_ref f = aux ;
+ (*f)((void *)s) ;
+ return 1 ;
+}
+
+void genset_deepfree (genset *g, freefunc_t_ref f)
+{
+ genset_iter(g, &freeiter, f) ;
+}
diff --git a/src/libdatastruct/gensetdyn_deepfree.c b/src/libdatastruct/gensetdyn_deepfree.c
new file mode 100644
index 0000000..8822bc3
--- /dev/null
+++ b/src/libdatastruct/gensetdyn_deepfree.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include <skalibs/functypes.h>
+#include <skalibs/gensetdyn.h>
+
+static int freeiter (char *s, void *aux)
+{
+ freefunc_t_ref f = aux ;
+ (*f)((void *)s) ;
+ return 1 ;
+}
+
+void gensetdyn_deepfree (gensetdyn *g, freefunc_t_ref f)
+{
+ gensetdyn_iter(g, &freeiter, f) ;
+ gensetdyn_free(g) ;
+}