Rename free procedures
This commit is contained in:
@@ -29,7 +29,7 @@ static bool desugar_class(regex_term_t *term)
|
||||
alternatives[i].contents = terms;
|
||||
}
|
||||
|
||||
regex_free_class_children(&term->class);
|
||||
regex_class_free(&term->class);
|
||||
term->type = REGEX_TERM_SUBEXPR;
|
||||
term->subexpr.count = term->subexpr.capacity = count;
|
||||
term->subexpr.contents = alternatives;
|
||||
|
||||
26
lib/regex.c
26
lib/regex.c
@@ -7,25 +7,16 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void regex_free_children(const regex_t *t)
|
||||
{
|
||||
if (NULL != t->contents) {
|
||||
for (int i = 0; i < t->count; ++i)
|
||||
regex_free_sequence_children(&t->contents[i]);
|
||||
free(t->contents);
|
||||
}
|
||||
}
|
||||
|
||||
void regex_free_sequence_children(const regex_sequence_t *s)
|
||||
static void sequence_free(const regex_sequence_t *s)
|
||||
{
|
||||
if (NULL != s->contents) {
|
||||
for (int i = 0; i < s->count; ++i) {
|
||||
switch (s->contents[i].type) {
|
||||
case REGEX_TERM_CLASS:
|
||||
regex_free_class_children(&s->contents[i].class);
|
||||
regex_class_free(&s->contents[i].class);
|
||||
break;
|
||||
case REGEX_TERM_SUBEXPR:
|
||||
regex_free_children(&s->contents[i].subexpr);
|
||||
regex_free(&s->contents[i].subexpr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -35,7 +26,16 @@ void regex_free_sequence_children(const regex_sequence_t *s)
|
||||
}
|
||||
}
|
||||
|
||||
void regex_free_class_children(const regex_class_t *c)
|
||||
void regex_free(const regex_t *t)
|
||||
{
|
||||
if (NULL != t->contents) {
|
||||
for (int i = 0; i < t->count; ++i)
|
||||
sequence_free(&t->contents[i]);
|
||||
free(t->contents);
|
||||
}
|
||||
}
|
||||
|
||||
void regex_class_free(const regex_class_t *c)
|
||||
{
|
||||
if (NULL != c->contents)
|
||||
free(c->contents);
|
||||
|
||||
@@ -50,8 +50,7 @@ typedef struct _regex_term {
|
||||
};
|
||||
} regex_term_t;
|
||||
|
||||
void regex_free_children(const regex_t *t);
|
||||
void regex_free_sequence_children(const regex_sequence_t *s);
|
||||
void regex_free_class_children(const regex_class_t *c);
|
||||
void regex_free(const regex_t *t);
|
||||
void regex_class_free(const regex_class_t *c);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user