diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-06-14 12:54:39 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-06-14 12:54:39 -0400 |
commit | 0b5d1bf482d72d488e8153bbd4683a901af781b7 (patch) | |
tree | 7faf2c126794b7050adbb3e0ac2a839f4e7adf10 /nodelink.c | |
parent | beab21ff3fc76c8a09b862888dcd0370411f5b8f (diff) | |
parent | de0e8322a5166d932b2b211be64022598971abde (diff) |
Merge branch 'correctness'
Diffstat (limited to 'nodelink.c')
-rw-r--r-- | nodelink.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -11,16 +11,22 @@ node* newnode(void) { return new; } +static char* empty(void) { + char* out = malloc(sizeof(char)); + *out = 0; + return out; +} + link* newlink(node* to) { link* new = malloc(sizeof(link)); - new->desc = ""; // preferred to NULL because it can be printed + new->desc = empty(); // preferred to NULL because it can be printed new->to = to; return new; } static void printlink(char* name, link* conn) { if (conn->desc[0]) - printf("%s: %s\n", name, conn->desc); + printf("%s: %s", name, conn->desc); else printf("%s\n", name); } @@ -31,7 +37,7 @@ static void printeach(strbstnode* loc, char reprint) { if (!reprint) printf(" "); // indent on subnode printlink(loc->ind, loc->data); // prints it // and subnodes if iterating over root tree (except root link) - if (reprint && strcmp(loc->ind,"root")) { + if (reprint && strcmp(loc->ind,"")) { // prints the link's target's link tree printeach( ( (link*)loc->data)->to->links->head, 0); } |