aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib/data/list.c
diff options
context:
space:
mode:
authorMarvin Borner2020-05-13 21:28:56 +0200
committerMarvin Borner2020-05-13 22:12:41 +0200
commita9c7529dcca845d98192ece62be70f752972216b (patch)
tree666d49ceb411a669abe6191151b2238fd7156c30 /src/kernel/lib/data/list.c
parente1a6ed079303dc7d218f1d5326a13b6755781271 (diff)
Replaced alloc.h with liballoc
And many more adaptions to the lib
Diffstat (limited to 'src/kernel/lib/data/list.c')
-rw-r--r--src/kernel/lib/data/list.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/kernel/lib/data/list.c b/src/kernel/lib/data/list.c
index 7ecc950..31e6631 100644
--- a/src/kernel/lib/data/list.c
+++ b/src/kernel/lib/data/list.c
@@ -7,7 +7,7 @@
struct list *list_create()
{
- struct list *list = kcalloc(sizeof(struct list), 1);
+ struct list *list = calloc(sizeof(struct list), 1);
return list;
}
@@ -29,13 +29,13 @@ void *list_remove_node(struct list *list, struct list_node *node)
node->next->prev = node->prev;
node->prev->next = node->next;
list->size--;
- kfree(node);
+ free(node);
}
return val;
}
struct list_node *list_insert_front(struct list *list, void *val)
{
- struct list_node *t = kcalloc(sizeof(struct list_node), 1);
+ struct list_node *t = calloc(sizeof(struct list_node), 1);
list->head->prev = t;
t->next = list->head;
t->val = val;
@@ -50,7 +50,7 @@ struct list_node *list_insert_front(struct list *list, void *val)
void list_insert_back(struct list *list, void *val)
{
- struct list_node *t = kcalloc(sizeof(struct list_node), 1);
+ struct list_node *t = calloc(sizeof(struct list_node), 1);
t->prev = list->tail;
if (list->tail)
list->tail->next = t;
@@ -72,7 +72,7 @@ void *list_remove_front(struct list *list)
list->head = t->next;
if (list->head)
list->head->prev = NULL;
- kfree(t);
+ free(t);
list->size--;
return val;
}
@@ -86,7 +86,7 @@ void *list_remove_back(struct list *list)
list->tail = t->prev;
if (list->tail)
list->tail->next = NULL;
- kfree(t);
+ free(t);
list->size--;
return val;
}
@@ -170,14 +170,14 @@ void list_destroy(struct list *list)
while (node != NULL) {
struct list_node *save = node;
node = node->next;
- kfree(save);
+ free(save);
}
- kfree(list);
+ free(list);
}
void listnode_destroy(struct list_node *node)
{
- kfree(node);
+ free(node);
}
// Conversion
@@ -199,13 +199,13 @@ struct list *str_split(const char *str, const char *delim, u32 *numtokens)
if (numtokens)
(*numtokens)++;
}
- kfree(s);
+ free(s);
return ret_list;
}
char *list_to_str(struct list *list, const char *delim)
{
- char *ret = kmalloc(256);
+ char *ret = malloc(256);
memset(ret, 0, 256);
int len = 0, ret_len = 256;
while (list_size(list) > 0) {
@@ -213,8 +213,7 @@ char *list_to_str(struct list *list, const char *delim)
int len_temp = strlen(temp);
if (len + len_temp + 1 + 1 > ret_len) {
ret_len = ret_len * 2;
- /* ret = krealloc(ret, ret_len); */
- ret = kmalloc(ret_len);
+ ret = realloc(ret, ret_len);
len = len + len_temp + 1;
}
strcat(ret, delim);