Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,7 @@ void mpc_ast_delete(mpc_ast_t *a) {
mpc_ast_delete(a->children[i]);
}

if (a->free) a->free(a->data);
free(a->children);
free(a->tag);
free(a->contents);
Expand All @@ -2520,6 +2521,7 @@ void mpc_ast_delete(mpc_ast_t *a) {
}

static void mpc_ast_delete_no_children(mpc_ast_t *a) {
if (a->free) a->free(a->data);
free(a->children);
free(a->tag);
free(a->contents);
Expand All @@ -2540,6 +2542,8 @@ mpc_ast_t *mpc_ast_new(const char *tag, const char *contents) {

a->children_num = 0;
a->children = NULL;
a->data = NULL;
a->free = NULL;
return a;

}
Expand Down
2 changes: 2 additions & 0 deletions mpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ mpc_parser_t *mpc_re(const char *re);
typedef struct mpc_ast_t {
char *tag;
char *contents;
void *data;
void (*free)(void*);
mpc_state_t state;
int children_num;
struct mpc_ast_t** children;
Expand Down