summaryrefslogtreecommitdiff
path: root/comp/cw/code/tokenizer/ads/dll
diff options
context:
space:
mode:
Diffstat (limited to 'comp/cw/code/tokenizer/ads/dll')
-rw-r--r--comp/cw/code/tokenizer/ads/dll/Makefile5
-rw-r--r--comp/cw/code/tokenizer/ads/dll/dll.c62
-rw-r--r--comp/cw/code/tokenizer/ads/dll/dll.h19
-rw-r--r--comp/cw/code/tokenizer/ads/dll/dll.obin2424 -> 0 bytes
-rwxr-xr-xcomp/cw/code/tokenizer/ads/dll/dlltestbin20640 -> 0 bytes
-rw-r--r--comp/cw/code/tokenizer/ads/dll/dlltest.c20
6 files changed, 0 insertions, 106 deletions
diff --git a/comp/cw/code/tokenizer/ads/dll/Makefile b/comp/cw/code/tokenizer/ads/dll/Makefile
deleted file mode 100644
index 651681d..0000000
--- a/comp/cw/code/tokenizer/ads/dll/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all: dll.c
- cc dll.c -c -o dll.o
-
-test: all
- cc dll.o dlltest.c -o dlltest
diff --git a/comp/cw/code/tokenizer/ads/dll/dll.c b/comp/cw/code/tokenizer/ads/dll/dll.c
deleted file mode 100644
index b24b13f..0000000
--- a/comp/cw/code/tokenizer/ads/dll/dll.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-typedef struct dll_t dll_t;
-
-typedef struct dll_t {
- void *data;
- dll_t *next;
- dll_t *prev;
-} dll_t;
-
-dll_t *dllalloc(){
- dll_t *output = malloc(sizeof(dll_t));
- if (output == NULL)
- return NULL;
- output->next = NULL;
- output->prev = NULL;
- return output;
-}
-
-void dllsetdata(dll_t *node, void *data){
- node->data = malloc(sizeof(data));
- memcpy(node->data, data, sizeof(data));
-}
-
-void dllsetnext(dll_t *node, dll_t *next){
- if (node->next == NULL) {
- node->next = next;
- node->next->prev = node;
- }
- else
- dllsetnext(node->next, next);
-}
-void dllsetprev(dll_t *node, dll_t *prev){
- if (node->prev == NULL) {
- node->prev = prev;
- node->prev->next = node;
- }
- else
- dllsetprev(node->prev, prev);
-}
-
-void *dllgetat(dll_t *head, int index){
- if (index == 0)
- return head->data;
- else {
- if (head->next != NULL) {
- return dllgetat(head->next, index - 1);
- }else {
- return NULL;
- }
- }
-}
-
-void dllfreeall(dll_t *head){
- if (head->next != NULL)
- dllfreeall(head->next);
- free(head->data);
- free(head);
-}
-
diff --git a/comp/cw/code/tokenizer/ads/dll/dll.h b/comp/cw/code/tokenizer/ads/dll/dll.h
deleted file mode 100644
index 44940ce..0000000
--- a/comp/cw/code/tokenizer/ads/dll/dll.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-typedef struct dll_t dll_t;
-
-typedef struct dll_t {
- void *data;
- dll_t *next;
- dll_t *prev;
-} dll_t;
-
-dll_t *dllalloc();
-void dllsetdata(dll_t *node, void *data);
-void dllsetnext(dll_t *node, dll_t *next);
-void dllsetprev(dll_t *node, dll_t *prev);
-void *dllgetat(dll_t *head, int index);
-void dllfreeall(dll_t *head);
-
diff --git a/comp/cw/code/tokenizer/ads/dll/dll.o b/comp/cw/code/tokenizer/ads/dll/dll.o
deleted file mode 100644
index 2c9a145..0000000
--- a/comp/cw/code/tokenizer/ads/dll/dll.o
+++ /dev/null
Binary files differ
diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest b/comp/cw/code/tokenizer/ads/dll/dlltest
deleted file mode 100755
index 83f900c..0000000
--- a/comp/cw/code/tokenizer/ads/dll/dlltest
+++ /dev/null
Binary files differ
diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest.c b/comp/cw/code/tokenizer/ads/dll/dlltest.c
deleted file mode 100644
index 4544d2e..0000000
--- a/comp/cw/code/tokenizer/ads/dll/dlltest.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-
-#include "dll.h"
-
-int main(){
- dll_t *head = dllalloc();
- dllsetdata(head, "hello");
-
- for (int i = 0; i < 3; i++){
- dll_t *node = dllalloc();
- dllsetdata(node, "hi");
- dllsetnext(head, node);
- }
-
- for (int i = 0; i < 4; i++)
- printf("%s\n", (char *)dllgetat(head, i));
- printf("%s\n", (char *)head->prev->next->data);
-
- dllfreeall(head);
-}