aboutsummaryrefslogtreecommitdiffstats
path: root/libnormalform_reset_indices_and_counts__.c
blob: f6b1790492e51f3df27180920d8a891ffd498751 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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