aboutsummaryrefslogtreecommitdiff
path: root/viz.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-12-17 16:27:23 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-12-17 16:27:23 -0800
commit484e1e33da7477b7278c9a3e9da878f0375dd75b (patch)
tree892979f8bf65fd9a1366c040fa4a090968fcaecf /viz.c
parent40be243004b095fe15bb2ece176692f8354cdf45 (diff)
Memory allocation failure checks, and a simpler new() function
Diffstat (limited to 'viz.c')
-rw-r--r--viz.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/viz.c b/viz.c
index 8e80574..a7148f5 100644
--- a/viz.c
+++ b/viz.c
@@ -7,6 +7,7 @@
#include <string.h>
#include "types.h"
+#include "utils.h"
#include "viz.h"
@@ -54,7 +55,7 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char *
if (RIGHT_TYPE(m)) {
//if (m->m->op->op != VM_REF) {
for (match_t *c = m->m->child; c; c = c->nextsibling) {
- *nextchild = calloc(1, sizeof(match_node_t));
+ *nextchild = new(match_node_t);
(*nextchild)->m = c;
nextchild = &((*nextchild)->next);
}
@@ -70,7 +71,7 @@ static void _visualize_matches(match_node_t *firstmatch, int depth, const char *
}
printf("\033[0;2m%s\033[0m", V);
} else {
- *nextchild = calloc(1, sizeof(match_node_t));
+ *nextchild = new(match_node_t);
(*nextchild)->m = m->m;
nextchild = &((*nextchild)->next);
printf("\033[%ldG\033[0;2m%s", 1+2*(m->m->start - text), V);