aboutsummaryrefslogtreecommitdiffstats
path: root/libnormalform_reset_indices_and_counts__.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-07-19 01:29:42 +0200
committerMattias Andrée <maandree@kth.se>2024-07-19 01:29:42 +0200
commit4294ec0ed06ee34920c9edaeebaeb8b65c720791 (patch)
treee0cded59452597c04fb38f403745a384675cb5f9 /libnormalform_reset_indices_and_counts__.c
downloadlibnormalform-4294ec0ed06ee34920c9edaeebaeb8b65c720791.tar.gz
libnormalform-4294ec0ed06ee34920c9edaeebaeb8b65c720791.tar.bz2
libnormalform-4294ec0ed06ee34920c9edaeebaeb8b65c720791.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libnormalform_reset_indices_and_counts__.c')
-rw-r--r--libnormalform_reset_indices_and_counts__.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libnormalform_reset_indices_and_counts__.c b/libnormalform_reset_indices_and_counts__.c
new file mode 100644
index 0000000..f6b1790
--- /dev/null
+++ b/libnormalform_reset_indices_and_counts__.c
@@ -0,0 +1,44 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+/**
+ * Undo `libnormalform_set_indices_and_counts__`
+ *
+ * This is needed because `libnormalform_set_indices_and_counts__`
+ * requires some otherwise unused memory to be properly initialised
+ *
+ * @param this The sentence that shall be recursively restored
+ */
+void
+(libnormalform_reset_indices_and_counts__)(LIBNORMALFORM_SENTENCE *this)
+{
+ LIBNORMALFORM_SENTENCE *head = NULL;
+
+ this->travel_count -= 1;
+ do {
+ this->travel_index = 0;
+ if (IS_BRANCH(this)) {
+ if (!--RIGHT(this)->travel_count)
+ PUSH(&head, RIGHT(this));
+ if (!--LEFT(this)->travel_count)
+ PUSH(&head, LEFT(this));
+ }
+ } while (POP(&head, &this));
+
+#undef UNMARK
+}
+
+
+#else
+
+
+CONST int
+main(void)
+{
+ return 0; /* indirectly tested */
+}
+
+
+#endif