diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-05-13 16:03:48 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-05-13 16:03:48 -0400 |
commit | 422ed5cfc5b046aa71ed8e18acaa1b724e872186 (patch) | |
tree | 7a1b328379874fb984fea2684db4d7bd54674e8a | |
parent | 11892095714466c9443de6ce158c4e5da404c0b1 (diff) |
changed freenext name in sb.c
-rw-r--r-- | sb.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -55,11 +55,12 @@ void insstr(sb* buf, char* str){ buf->loc += rem; } -sbnode* freenodenext(sbnode* node){ +static sbnode* freenext(sbnode* node){ sbnode* out = node->next; free(node->str); free(node); - return out; + if (node != out) return out; + else return node; } char* decompose(sb* buf){ @@ -77,7 +78,7 @@ char* decompose(sb* buf){ // and its iterator char* pos = str; // for every node, - for (sbnode* cur = buf->head; cur != NULL; cur = freenodenext(cur)){ + for (sbnode* cur = buf->head; cur != NULL; cur = freenext(cur)){ size_t slen = strlen(cur->str); memcpy(pos, cur->str, slen); // copy pos += slen; |