summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-17 16:19:10 +0200
committerAnton Kling <anton@kling.gg>2024-10-17 16:19:10 +0200
commitf5ac81dcf2e58d7e1a128742ddd09942513e63cc (patch)
tree503e1ed8dc43d1f6a1f3c09454f24b10dc1a5bf0 /kernel
parent43e0b9dd92eaf56ed58959e696b3f53100a0da69 (diff)
kernel: Use realloc instead of malloc+free
Diffstat (limited to 'kernel')
-rw-r--r--kernel/lib/relist.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/lib/relist.c b/kernel/lib/relist.c
index a681435..795b07a 100644
--- a/kernel/lib/relist.c
+++ b/kernel/lib/relist.c
@@ -80,7 +80,7 @@ int relist_add(struct relist *list, void *value, u32 *index) {
u32 entry;
if (!relist_find_free_entry(list, &entry)) {
u32 new_capacity = list->bitmap_capacity + 1;
- u64 *new_allocation = kcalloc(sizeof(u64), new_capacity);
+ u64 *new_allocation = krecalloc(list->bitmap, sizeof(u64), new_capacity);
if (!new_allocation) {
return 0;
}
@@ -93,7 +93,6 @@ int relist_add(struct relist *list, void *value, u32 *index) {
if (list->bitmap) {
size_t to_copy = min(list->bitmap_capacity, new_capacity) * sizeof(u64);
memcpy(new_allocation, list->bitmap, to_copy);
- kfree(list->bitmap);
}
list->bitmap = new_allocation;
list->bitmap_capacity = new_capacity;