aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2023-12-06 17:16:54 -0500
committerHolden Rohrer <hr@hrhr.dev>2023-12-06 17:19:17 -0500
commit0b4bd76e6bcb46074719f950f2b8e2cd464d117d (patch)
treeb16733a2bbf99a89a3f24e24a657ec33161e0263
parent47ff6a368e1925cdc6d9fa197252c62855ec2bab (diff)
old changes I had lying aroundHEADmaster
Looks like I was trying to implement an splint linter here in order to disprove null check errors. This whole thing seems pretty useless except as a C exercise. Why not just use a Wiki or Knuth's WEB or org-mode or a text file with indentation?
-rw-r--r--README5
-rw-r--r--ll.c9
-rw-r--r--ll.h2
3 files changed, 13 insertions, 3 deletions
diff --git a/README b/README
index 4d5de85..c83be3a 100644
--- a/README
+++ b/README
@@ -14,3 +14,8 @@ For every line,
- dot or other, take literally (as a desc)
Always trim ending spaces
+
+# bugs
+
+the possibility that `malloc == NULL` is pretty much ignored, memory
+handling is probably lossy, and pointer chasing is inefficient
diff --git a/ll.c b/ll.c
index 910b869..3481b8b 100644
--- a/ll.c
+++ b/ll.c
@@ -1,9 +1,14 @@
#include <stdlib.h>
+#include <assert.h>
#include "ll.h"
-llnode* appendll(llnode* tail, char* str){
+llnode* appendll(llnode* tail, /*@nottemp@*/char* str){
llnode* new = malloc(sizeof(llnode));
- if (tail != NULL) tail->next = new;
+ assert(new != NULL);
+ if (tail != NULL) {
+ assert(tail->next == NULL);
+ tail->next = new;
+ }
new->str = str;
new->next = NULL;
return new;
diff --git a/ll.h b/ll.h
index 9a80182..cea6010 100644
--- a/ll.h
+++ b/ll.h
@@ -7,6 +7,6 @@ typedef struct llnode {
struct llnode* next;
} llnode;
-llnode* appendll(llnode* tail, char* str);
+llnode* appendll(llnode* tail, /*@notnull@*/char* str);
#endif