aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-10-05 21:49:54 +0200
commitc5fcf7179a83ef65c86c6a4a390029149e518649 (patch)
treed29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c
parentf8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff)
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c')
-rw-r--r--Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c79
1 files changed, 0 insertions, 79 deletions
diff --git a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c b/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c
deleted file mode 100644
index 16113ac..0000000
--- a/Semestr 4/sieci/pracownia2/franciszek_malinka/linked_list.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Program: router
- * Autor: Franciszek Malinka, 316093
- */
-
-#include "linked_list.h"
-#include <stdlib.h>
-#include <stdint.h>
-
-node_t *_next(node_t *node) {
- return (node == NULL) ? NULL : node->next;
-}
-
-void _insert(node_t **head, void *data, size_t data_size) {
- node_t *new_node = (node_t *)malloc(sizeof(node_t));
- new_node->data = malloc(data_size);
- for (int i = 0; i < data_size; i++)
- *(uint8_t *)(new_node->data + i) = *(uint8_t *)(data + i);
- new_node->next = *head;
- *head = new_node;
-}
-
-void _free_node(node_t *node) {
- free(node->data);
- free(node);
-}
-
-void _erase(node_t **head) {
- node_t *next_node = _next(*head);
- _free_node(*head);
- *head = next_node;
-}
-
-void _free_list(node_t *head) {
- if (head == NULL) return;
- _free_list(head->next);
- _free_node(head);
-}
-
-list_t create_list() {
- list_t ret;
- ret.head = NULL;
- ret.it = NULL;
- return ret;
-}
-
-void insert(list_t *list, void *data, size_t data_size) {
- _insert(&list->head, data, data_size);
-}
-
-void erase(list_t *list) {
- _erase(&list->head);
-}
-
-void erase_it(list_t *list) {
- if(list->it == NULL) return;
- if(list->prev_it == NULL) {
- erase(list);
- reset(list);
- return;
- }
- list->prev_it->next = _next(list->it);
- _free_node(list->it);
- list->it = list->prev_it->next;
-}
-
-void iterate(list_t *list) {
- list->prev_it = list->it;
- list->it = _next(list->it);
-}
-
-void reset(list_t *list) {
- list->prev_it = NULL;
- list->it = list->head;
-}
-
-void free_list(list_t *list) {
- _free_list(list->head);
-} \ No newline at end of file