aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/parse.c b/src/parse.c
index b6645fd..9a8af45 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -111,6 +111,16 @@ struct bloc_parsed *parse_bloc(const void *bloc)
return parsed;
}
+void free_bloc(struct bloc_parsed *bloc)
+{
+ for (size_t i = 0; i < bloc->length; i++) {
+ free_term(bloc->entries[i]);
+ }
+
+ free(bloc->entries);
+ free(bloc);
+}
+
static struct term *rec_bloc(struct term *term, struct bloc_parsed *bloc)
{
switch (term->type) {
@@ -124,10 +134,8 @@ static struct term *rec_bloc(struct term *term, struct bloc_parsed *bloc)
case VAR:
break;
case REF:
- if (term->u.ref.index >= bloc->length) {
+ if (term->u.ref.index >= bloc->length)
fatal("invalid entry reference\n");
- return 0;
- }
memcpy(term,
bloc->entries[bloc->length - term->u.ref.index - 1],
sizeof(*term));