summaryrefslogtreecommitdiff
path: root/Kernel/Heap/kmalloc.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-11 13:19:33 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-11 14:14:51 +0200
commitd38b4e46655758c1f924451af119c302bcf4c009 (patch)
tree0610e93e6dde8980854aa665bea245a3d687014f /Kernel/Heap/kmalloc.cpp
parent98080497d28540a48bec50a92b356a4edaddc235 (diff)
downloadserenity-d38b4e46655758c1f924451af119c302bcf4c009.zip
Kernel: Add kfree_sized(), kfree() with a known allocation size
C++14 gave us sized operator delete, but we haven't been taking advantage of it. Let's get to a point where it can help us by adding kfree_sized(void*, size_t).
Diffstat (limited to 'Kernel/Heap/kmalloc.cpp')
-rw-r--r--Kernel/Heap/kmalloc.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp
index 6b9f9cdc6b..bee099cc53 100644
--- a/Kernel/Heap/kmalloc.cpp
+++ b/Kernel/Heap/kmalloc.cpp
@@ -270,6 +270,12 @@ void* kmalloc(size_t size)
return ptr;
}
+void kfree_sized(void* ptr, size_t size)
+{
+ (void)size;
+ return kfree(ptr);
+}
+
void kfree(void* ptr)
{
if (!ptr)
@@ -333,9 +339,9 @@ void operator delete(void* ptr) noexcept
return kfree(ptr);
}
-void operator delete(void* ptr, size_t) noexcept
+void operator delete(void* ptr, size_t size) noexcept
{
- return kfree(ptr);
+ return kfree_sized(ptr, size);
}
void operator delete[](void* ptr) noexcept
@@ -343,9 +349,9 @@ void operator delete[](void* ptr) noexcept
return kfree(ptr);
}
-void operator delete[](void* ptr, size_t) noexcept
+void operator delete[](void* ptr, size_t size) noexcept
{
- return kfree(ptr);
+ return kfree_sized(ptr, size);
}
void get_kmalloc_stats(kmalloc_stats& stats)