From 3878cd76e6de75d4427219c823947fac19a29a4f Mon Sep 17 00:00:00 2001 From: Daniel Holden Date: Sun, 22 Feb 2015 17:38:47 +0000 Subject: [PATCH] print function now works for null tree --- mpc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mpc.c b/mpc.c index be9d88b..d099daf 100644 --- a/mpc.c +++ b/mpc.c @@ -2486,6 +2486,7 @@ void mpc_ast_delete(mpc_ast_t *a) { int i; if (a == NULL) { return; } + for (i = 0; i < a->children_num; i++) { mpc_ast_delete(a->children[i]); } @@ -2599,6 +2600,11 @@ mpc_ast_t *mpc_ast_state(mpc_ast_t *a, mpc_state_t s) { static void mpc_ast_print_depth(mpc_ast_t *a, int d, FILE *fp) { int i; + + if (a == NULL) { + fprintf(fp, "NULL\n"); + } + for (i = 0; i < d; i++) { fprintf(fp, " "); } if (strlen(a->contents)) {