aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/lib/data
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
parente1a6ed079303dc7d218f1d5326a13b6755781271 (diff)
Replaced alloc.h with liballoc
And many more adaptions to the lib
Diffstat (limited to 'src/kernel/lib/data')
-rw-r--r--src/kernel/lib/data/list.c25
-rw-r--r--src/kernel/lib/data/tree.c9
2 files changed, 17 insertions, 17 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);
diff --git a/src/kernel/lib/data/tree.c b/src/kernel/lib/data/tree.c
index 65b8433..9758ec1 100644
--- a/src/kernel/lib/data/tree.c
+++ b/src/kernel/lib/data/tree.c
@@ -1,15 +1,16 @@
#include <lib/data.h>
#include <memory/alloc.h>
+#include <stddef.h>
#include <stdint.h>
struct tree *tree_create()
{
- return (struct tree *)kcalloc(sizeof(struct tree), 1);
+ return (struct tree *)calloc(sizeof(struct tree), 1);
}
struct tree_node *treenode_create(void *value)
{
- struct tree_node *n = kcalloc(sizeof(struct tree_node), 1);
+ struct tree_node *n = calloc(sizeof(struct tree_node), 1);
n->value = value;
n->children = list_create();
return n;
@@ -17,7 +18,7 @@ struct tree_node *treenode_create(void *value)
struct tree_node *tree_insert(struct tree *tree, struct tree_node *subroot, void *value)
{
- struct tree_node *treenode = kcalloc(sizeof(struct tree_node), 1);
+ struct tree_node *treenode = calloc(sizeof(struct tree_node), 1);
treenode->children = list_create();
treenode->value = value;
@@ -62,7 +63,7 @@ void tree_remove(struct tree *tree, struct tree_node *remove_node)
struct tree_node *parent = tree_find_parent(tree, remove_node, &child_index);
if (parent != NULL) {
struct tree_node *freethis = list_remove_by_index(parent->children, child_index);
- kfree(freethis);
+ free(freethis);
}
}