aboutsummaryrefslogtreecommitdiffstats
path: root/libautomata_destroy_automaton.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-28 14:00:33 +0100
committerMattias Andrée <m@maandree.se>2026-02-22 15:26:49 +0100
commite12b1cc372e0c64a7c2fb76bc08a72381808d89d (patch)
treefc09dedc79b497baef6ba43d68d8fc2bd2f69fa1 /libautomata_destroy_automaton.c
parentfix readme (diff)
downloadlibautomata-e12b1cc372e0c64a7c2fb76bc08a72381808d89d.tar.gz
libautomata-e12b1cc372e0c64a7c2fb76bc08a72381808d89d.tar.bz2
libautomata-e12b1cc372e0c64a7c2fb76bc08a72381808d89d.tar.xz
Some fixes and generic automatonHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libautomata_destroy_automaton.c')
-rw-r--r--libautomata_destroy_automaton.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libautomata_destroy_automaton.c b/libautomata_destroy_automaton.c
new file mode 100644
index 0000000..ef27bc1
--- /dev/null
+++ b/libautomata_destroy_automaton.c
@@ -0,0 +1,17 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+void
+libautomata_destroy_automaton(struct libautomata_automaton *automaton)
+{
+ size_t i;
+ if (automaton->nodes)
+ for (i = 0; i < automaton->nnodes; i++)
+ if (automaton->nodes[i] && automaton->nodes[i].destory)
+ (*automaton->nodes[i].destory)(&automaton->nodes[i]);
+ automaton->start = NULL;
+ automaton->current = NULL;
+ automaton->nodes = NULL;
+ automaton->nnodes = 0;
+}