aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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