diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-11 20:00:21 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2022-12-11 20:00:21 +0100 |
| commit | f29d35faf7cc574a1a8c109f2f609db9d3d4b5ef (patch) | |
| tree | dfd2fcbf20f3d37ffe1f19be3d0a9afb7fd24d86 /list.c | |
| parent | 24af775b5041cbed67dfc84f3a0d67850a4b6a1b (diff) | |
bazinga
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; } |
