MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / liballoc_alloc

Function liballoc_alloc

Kernel/src/liballoc/_liballoc.cpp:32–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void* liballoc_alloc(size_t pages) {
33 void* addr = (void*)Memory::KernelAllocate4KPages(pages);
34 for (size_t i = 0; i < pages; i++)
35 {
36 uint64_t phys = Memory::AllocatePhysicalMemoryBlock();
37 Memory::KernelMapVirtualMemory4K(phys, (uint64_t)addr + i * PAGE_SIZE_4K, 1);
38 }
39
40 memset(addr, 0, pages * PAGE_SIZE_4K);
41
42 return addr;
43}
44
45int liballoc_free(void* addr, size_t pages) {
46 for(size_t i = 0; i < pages; i++){

Callers 1

allocate_new_pageFunction · 0.85

Calls 4

KernelAllocate4KPagesFunction · 0.85
KernelMapVirtualMemory4KFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected