43 lines
840 B
C
43 lines
840 B
C
/*
|
|
* Copyright (c) Camden Dixie O'Brien
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
#include "regex.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
void parse_free_tree_children(const parse_tree_t *t)
|
|
{
|
|
if (NULL != t->contents) {
|
|
for (int i = 0; i < t->count; ++i)
|
|
parse_free_sequence_children(&t->contents[i]);
|
|
free(t->contents);
|
|
}
|
|
}
|
|
|
|
void parse_free_sequence_children(const parse_sequence_t *s)
|
|
{
|
|
if (NULL != s->contents) {
|
|
for (int i = 0; i < s->count; ++i) {
|
|
switch (s->contents[i].type) {
|
|
case PARSE_TERM_CLASS:
|
|
parse_free_class_children(&s->contents[i].class);
|
|
break;
|
|
case PARSE_TERM_SUBEXPR:
|
|
parse_free_tree_children(&s->contents[i].subexpr);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
free(s->contents);
|
|
}
|
|
}
|
|
|
|
void parse_free_class_children(const parse_class_t *c)
|
|
{
|
|
if (NULL != c->contents)
|
|
free(c->contents);
|
|
}
|