diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-02-27 09:21:43 +0100 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-02-27 09:21:43 +0100 |
| commit | 3fb836101a2032e93f7b82c924ce208d7377a5ea (patch) | |
| tree | 52f9aa1f5316b9938e74f43637c0641803fda01a /arch/x86_64/src/kernel/main.cpp | |
| parent | cd42c21f2460751428b3e1b4ae07ea0b924967bc (diff) | |
| parent | 2f1f0fa8b0dc1893219be68ab8bf653b5d6349fb (diff) | |
| download | teachos-3fb836101a2032e93f7b82c924ce208d7377a5ea.tar.xz teachos-3fb836101a2032e93f7b82c924ce208d7377a5ea.zip | |
Merge branch 'feat_new_delete_override' into 'develop_ba'
new delete override
See merge request teachos/kernel!4
Diffstat (limited to 'arch/x86_64/src/kernel/main.cpp')
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 681f960..472aed5 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -1,8 +1,7 @@ #include "arch/kernel/main.hpp" #include "arch/memory/heap/bump_allocator.hpp" -#include "arch/memory/heap/concept.hpp" -#include "arch/memory/heap/linked_list_allocator.hpp" +#include "arch/memory/heap/global_heap_allocator.hpp" #include "arch/memory/main.hpp" #include "arch/memory/multiboot/reader.hpp" #include "arch/video/vga/text.hpp" @@ -22,12 +21,8 @@ namespace teachos::arch::kernel auto heap_test() -> void { - memory::heap::linked_list_allocator heap_allocator{memory::heap::HEAP_START, - memory::heap::HEAP_START + memory::heap::HEAP_SIZE}; - auto test = heap_allocator.allocate(1024); - auto test2 = new (test) memory::multiboot::memory_information{}; - auto test3 = new (static_cast<void *>(static_cast<memory::multiboot::memory_information *>(test) + 1)) - memory::multiboot::memory_information{}; + auto test2 = new memory::multiboot::memory_information{}; + auto test3 = new memory::multiboot::memory_information{}; auto test4 = *test2; auto test5 = *test3; test4.kernel_end = 5000; @@ -42,18 +37,11 @@ namespace teachos::arch::kernel test2->kernel_end = 2000; test2->kernel_start = 1000; test2->multiboot_start = 2000; - heap_allocator.deallocate(test, 1024); + delete test2; + delete test3; - auto test9 = heap_allocator.allocate(1024); - auto test10 = heap_allocator.allocate(1024); - auto test11 = heap_allocator.allocate(1024); - heap_allocator.deallocate(test9, 1024); - auto test12 = heap_allocator.allocate(1024); - auto test13 = heap_allocator.allocate(1024); - heap_allocator.deallocate(test11, 1024); - heap_allocator.deallocate(test10, 1024); - heap_allocator.deallocate(test13, 1024); - heap_allocator.deallocate(test12, 1024); + auto test9 = new int(50); + delete test9; } auto main() -> void @@ -64,8 +52,10 @@ namespace teachos::arch::kernel video::vga::text::newline(); memory::initialize_memory_management(); - // stack_overflow_test(0); + + memory::heap::global_heap_allocator::register_heap_allocator(memory::heap::heap_allocator_type::LINKED_LIST); + heap_test(); } } // namespace teachos::arch::kernel |
