diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-12-17 16:27:23 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-12-17 16:27:23 -0800 |
| commit | 484e1e33da7477b7278c9a3e9da878f0375dd75b (patch) | |
| tree | 892979f8bf65fd9a1366c040fa4a090968fcaecf /viz.c | |
| parent | 40be243004b095fe15bb2ece176692f8354cdf45 (diff) | |
Memory allocation failure checks, and a simpler new() function
Diffstat (limited to 'viz.c')
| -rw-r--r-- | viz.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |
