From 42b7aab1ae5b2fcb8dfe06117349bf0e371a3a99 Mon Sep 17 00:00:00 2001 From: starnakin Date: Mon, 16 Sep 2024 16:19:38 +0200 Subject: [PATCH] remove bonus --- headers/list.h | 7 --- src/ft_list_push_front.asm | 27 ---------- src/ft_list_size.asm | 19 ------- test/test.c | 105 ------------------------------------- 4 files changed, 158 deletions(-) delete mode 100644 headers/list.h delete mode 100644 src/ft_list_push_front.asm delete mode 100644 src/ft_list_size.asm diff --git a/headers/list.h b/headers/list.h deleted file mode 100644 index 684d375..0000000 --- a/headers/list.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -typedef struct s_list -{ - void *data; - struct s_list *next; -} t_list; \ No newline at end of file diff --git a/src/ft_list_push_front.asm b/src/ft_list_push_front.asm deleted file mode 100644 index 7f52808..0000000 --- a/src/ft_list_push_front.asm +++ /dev/null @@ -1,27 +0,0 @@ -extern malloc - -section .text - global ft_list_push_front - ft_list_push_front: - - push rdi - push rsi - - mov rdi, 16 - - call malloc wrt ..plt - - cmp rax, 0 - je out - - pop rsi - pop rdi - - mov rdx, [rdi] - mov [rax + 0], rsi ; .data = arg#1 - mov [rax + 8], rdx ; .next = *arg#0 - - mov [rdi], rax - - out: - ret \ No newline at end of file diff --git a/src/ft_list_size.asm b/src/ft_list_size.asm deleted file mode 100644 index 5b6f70e..0000000 --- a/src/ft_list_size.asm +++ /dev/null @@ -1,19 +0,0 @@ -section .text - global ft_list_size - - ft_list_size: - xor rcx, rcx - - loop: - cmp QWORD [rdi + 8], 0 - je out - - mov rdi, [rdi + 8] - - inc rcx - - jmp loop - - out: - mov rax, rcx - ret diff --git a/test/test.c b/test/test.c index 57365c1..2fde419 100644 --- a/test/test.c +++ b/test/test.c @@ -75,97 +75,6 @@ void multiple_test_atoi_base(char *(*own_func)(char *, const char *), const char } } -void destroy_list(t_list *root, void *(destroy_data)(void *)) -{ - t_list *current = root; - t_list *prev; - - while (current != NULL) - { - prev = current; - if (current->data) - if (destroy_data) - destroy_data(current->data); - current = current->next; - free(prev); - } -} - -t_list *create_list(size_t len) -{ - t_list *root; - t_list *current = root; - - root = malloc(sizeof(t_list)); - if (root == NULL) - return NULL; - - current = root; - for (size_t i = 0; i < len; i++) - { - current->next = malloc(sizeof(t_list)); - current->data = (void *) i; - if (current->next == NULL) - { - destroy_list(current, NULL); - return NULL; - } - current = current->next; - } - current->next = NULL; - return root; -} - -#define nb_random_test 10 -#define nb_specific_test 1 - -void multiple_test_list_size() -{ - size_t len; - t_list *root; - size_t specific_size[nb_specific_test] = {0}; - - srand(time(NULL)); - - for (size_t i = 0; i < nb_random_test + nb_specific_test; i++) - { - len = i < nb_specific_test ? specific_size[i] : rand() % 100; - - root = create_list(len); - if (root == NULL) - return; - test_int(len, ft_list_size(root)); - destroy_list(root, NULL); - printf("\n"); - } -} - -void multiple_test_push_front() -{ - size_t len; - t_list *root; - - srand(time(NULL)); - - for (size_t i = 0; i < nb_random_test; i++) - { - len = rand() % 100; - - root = create_list(len); - if (root == NULL) - return; - ft_list_push_front(&root, (void *) 101); - printf("data: "); - test_size_t((size_t) root->data, 101); - printf(" data-next: "); - test_size_t((size_t) root->next->data, 0); - printf(" list-size: "); - test_int(len + 1, ft_list_size(root)); - printf("\n"); - destroy_list(root, NULL); - } -} - void multiple_test_strdup(const char * const *values) { char *tmp; @@ -200,18 +109,4 @@ int main() const char *strdup_tests[] = {"yo", "", "bonjour", "co\0fgf", NULL}; multiple_test_strdup(strdup_tests); printf("\n"); - -/* - printf("ATOI_BASE\n"); - const char *atoi_base_tests[][2] = {{"0123", ""}, {"0123", "0"}, {"0123", "0123456789"}, {"bonjour", "bonjour"}, {"", ""}, {"bonjour", "salut"}, {"co\0fgf", "co\0fgf"}, NULL}; - multiple_test_int_2(strcmp, ft_strcmp, strcmp_tests); - printf("\n");*/ - - printf("FT_LIST_SIZE\n"); - multiple_test_list_size(); - printf("\n"); - - printf("FT_LIST_PUSH_FRONT\n"); - multiple_test_push_front(); - printf("\n"); } \ No newline at end of file