diff options
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | ll.c | 9 | ||||
-rw-r--r-- | ll.h | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -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 @@ -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; @@ -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 |