From 0b4bd76e6bcb46074719f950f2b8e2cd464d117d Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Wed, 6 Dec 2023 17:16:54 -0500
Subject: old changes I had lying around
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?
---
README | 5 +++++
ll.c | 9 +++++++--
ll.h | 2 +-
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
+#include
#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
--
cgit