diff --git a/src/llist.c b/src/llist.c index 4b8565f..228d813 100644 --- a/src/llist.c +++ b/src/llist.c @@ -26,7 +26,7 @@ llist *llistTail(llist *l) { return tail; } -/* creates new node from data and appends it to head +/* creates new node from data and appends it to tail * */ llist *llistAppend(llist *head, void *data) { @@ -41,7 +41,10 @@ llist *llistAppend(llist *head, void *data) { return new; } -void *llistGet(llist *head, void *key) { +/* + * return Node containing key or NULL + */ +llist *llistGet(llist *head, void *key) { llist *c = head; while (c != NULL) { if (key == c) { @@ -51,6 +54,7 @@ void *llistGet(llist *head, void *key) { } return NULL; } + bool llistContains(llist *head, void *key) { return llistGet(head, key) != NULL; } diff --git a/src/llist.h b/src/llist.h index 679b33a..42fdda5 100644 --- a/src/llist.h +++ b/src/llist.h @@ -14,7 +14,7 @@ llist *llistNew(void *data, int (*cmpFN)(void *a, void *b)); // create new node with data and append to tail of head llist *llistAppend(llist *head, void *data); // return llistNode that contains key or NULL -void *llistGet(llist *head, void *key); +llist *llistGet(llist *head, void *key); // TURE if llist contains key bool llistContains(llist *head, void *key); // free llist node (Does Not free data it contains!!)