diff options
| author | Mattias Andrée <m@maandree.se> | 2026-06-04 18:13:03 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-06-04 18:13:03 +0200 |
| commit | 6e15f057ebc59a0d5bdb94675548d1dde5030d60 (patch) | |
| tree | c4305d3245448062d89480aafe69b2c75d0f07d9 | |
| parent | Some fixes and generic automaton (diff) | |
| download | libautomata-6e15f057ebc59a0d5bdb94675548d1dde5030d60.tar.gz libautomata-6e15f057ebc59a0d5bdb94675548d1dde5030d60.tar.bz2 libautomata-6e15f057ebc59a0d5bdb94675548d1dde5030d60.tar.xz | |
Some fixes
Signed-off-by: Mattias Andrée <m@maandree.se>
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | libautomata.h | 3 | ||||
| -rw-r--r-- | libautomata_destroy_automaton.c | 2 | ||||
| -rw-r--r-- | libautomata_execute_automaton.c | 5 | ||||
| -rw-r--r-- | libautomata_reset_automaton.c | 10 |
5 files changed, 18 insertions, 4 deletions
@@ -1,6 +1,6 @@ ISC License -© 2025 Mattias Andrée <m@maandree.se> +© 2025, 2026 Mattias Andrée <m@maandree.se> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/libautomata.h b/libautomata.h index 82d4cdd..a9c7513 100644 --- a/libautomata.h +++ b/libautomata.h @@ -7,6 +7,7 @@ /* Generic automaton */ +struct libautomata_automaton; enum libautomata_automaton_state { LIBAUTOMATA_AUTOMATON_RUNNING, LIBAUTOMATA_AUTOMATON_ABORTED, @@ -57,7 +58,7 @@ typedef struct libautomata_mp_automaton LIBAUTOMATA_MP_AUTOMATON; void libautomata_reset_mp_automaton(LIBAUTOMATA_MP_AUTOMATON *automaton); LIBAUTOMATA_MP_AUTOMATON *libautomata_clone_mp_automaton(const LIBAUTOMATA_MP_AUTOMATON *automaton); LIBAUTOMATA_MP_AUTOMATON *libautomata_compile_mp_automaton(const void *pattern, size_t length, size_t elemsize); -void *libautomata_execute_mp_automaton(,LIBAUTOMATA_MP_AUTOMATON *automaton, const void *haystack, size_t length); +void *libautomata_execute_mp_automaton(LIBAUTOMATA_MP_AUTOMATON *automaton, const void *haystack, size_t length); #endif diff --git a/libautomata_destroy_automaton.c b/libautomata_destroy_automaton.c index ef27bc1..70532ee 100644 --- a/libautomata_destroy_automaton.c +++ b/libautomata_destroy_automaton.c @@ -8,7 +8,7 @@ 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) + if (automaton->nodes[i].destory) (*automaton->nodes[i].destory)(&automaton->nodes[i]); automaton->start = NULL; automaton->current = NULL; diff --git a/libautomata_execute_automaton.c b/libautomata_execute_automaton.c new file mode 100644 index 0000000..24cf924 --- /dev/null +++ b/libautomata_execute_automaton.c @@ -0,0 +1,5 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +extern inline void libautomata_execute_automaton(struct libautomata_automaton *, const void *, void **, size_t *); diff --git a/libautomata_reset_automaton.c b/libautomata_reset_automaton.c index 24cf924..5826512 100644 --- a/libautomata_reset_automaton.c +++ b/libautomata_reset_automaton.c @@ -2,4 +2,12 @@ #include "common.h" -extern inline void libautomata_execute_automaton(struct libautomata_automaton *, const void *, void **, size_t *); +void +libautomata_reset_automaton(struct libautomata_automaton *automaton) +{ + size_t i; + for (i = 0u; i < automaton->nnodes; i++) + automaton->nodes[i].reset(&automaton->nodes[i]); + automaton->current = automaton->start; + automaton->state = LIBAUTOMATA_AUTOMATON_RUNNING; +} |
