diff options
Diffstat (limited to 'comp/cw/code/tokenizer/ads/ll/ll.c')
-rw-r--r-- | comp/cw/code/tokenizer/ads/ll/ll.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/comp/cw/code/tokenizer/ads/ll/ll.c b/comp/cw/code/tokenizer/ads/ll/ll.c deleted file mode 100644 index c45ab0c..0000000 --- a/comp/cw/code/tokenizer/ads/ll/ll.c +++ /dev/null @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - |