From 422ed5cfc5b046aa71ed8e18acaa1b724e872186 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Wed, 13 May 2020 16:03:48 -0400
Subject: changed freenext name in sb.c
---
sb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sb.c b/sb.c
index 06ee8d9..e1cbd63 100644
--- a/sb.c
+++ b/sb.c
@@ -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;
--
cgit