diff options
Diffstat (limited to 'list.c')
| -rw-r--r-- | list.c | 33 |
1 files changed, 4 insertions, 29 deletions
@@ -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 <https://www.gnu.org/licenses/>. -*/ - #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; } |
