From f29d35faf7cc574a1a8c109f2f609db9d3d4b5ef Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 11 Dec 2022 20:00:21 +0100 Subject: bazinga --- list.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'list.c') diff --git a/list.c b/list.c index 35c41eb..f186285 100644 --- a/list.c +++ b/list.c @@ -1,48 +1,24 @@ -/* -* Copyright 2019 Aldrik Ramaekers -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - #include "include/list.h" -list list_create(u16 size) +list list_create(u16 size, allocator* al) { list l; l.size = size; l.count = 0; l.start = 0; + l.al = al; return l; } void list_destroy(list* list) { - list_item *prev = 0; - list_item *current_item = list->start; - while(current_item) - { - prev = current_item; - current_item = current_item->next; - mem_free(prev); - } - + list->start = 0; list->count = 0; } list_item *list_push(list *list, void *data) { - list_item *item = mem_alloc(sizeof(list_item)); + list_item *item = allocator_alloc(list->al, sizeof(list_item)); item->next = 0; item->data = data; @@ -100,7 +76,6 @@ void list_remove_at(list *list, u32 index) else list->start = current_item->next; - mem_free(current_item); goto done; } -- cgit v1.2.3-70-g09d2