[kutil] Flag static allocated vectors

ktuil::vector can take a static area of memory as its initial memory,
but the case was never handled where it outgrew that memory and had to
reallocate. Steal the high bit from the capacity value to indicate the
current memory should not be kfree()'d. Also added checks in the heap
allocator to make sure pointers look valid.
This commit is contained in:
Justin C. Miller
2021-01-30 20:07:30 -08:00
parent 3595c3a440
commit c364e30240
4 changed files with 37 additions and 23 deletions

View File

@@ -7,7 +7,8 @@
#include "vm_space.h"
// The initial memory for the array of areas for the kernel space
static uint64_t kernel_areas[16];
constexpr size_t num_kernel_areas = 8;
static uint64_t kernel_areas[num_kernel_areas * 2];
int
vm_space::area::compare(const vm_space::area &o) const
@@ -28,7 +29,7 @@ vm_space::area::operator==(const vm_space::area &o) const
vm_space::vm_space(page_table *p) :
m_kernel {true},
m_pml4 {p},
m_areas {reinterpret_cast<vm_space::area*>(kernel_areas), 0, 8}
m_areas {reinterpret_cast<vm_space::area*>(kernel_areas), 0, num_kernel_areas}
{}
vm_space::vm_space() :