blob: b22089ee0c006b1277d1baa7325278bdc96a8e07 (
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
|
// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdlib.h>
#include <free.h>
void free_term(struct term *term)
{
switch (term->type) {
case ABS:
free_term(term->u.abs.term);
free(term);
break;
case APP:
free_term(term->u.app.lhs);
free_term(term->u.app.rhs);
free(term);
break;
case VAR:
free(term);
break;
case REF:
free(term);
break;
default:
fprintf(stderr, "Invalid type %d\n", term->type);
}
}
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);
}
|