Testing vector indexing

This commit is contained in:
Victor Olin 2023-03-23 13:32:24 +01:00
parent fb4cd8eb9b
commit e745593d94
2 changed files with 14 additions and 11 deletions

View file

@ -130,7 +130,8 @@ namespace GC
// Check if there are any freed chunks large enough for current request
for (size_t i = 0; i < heap.m_freed_chunks.size(); i++)
{
auto chunk = Heap::get_at(heap.m_freed_chunks, i);
// auto chunk = Heap::get_at(heap.m_freed_chunks, i);
auto chunk = heap.m_freed_chunks[i];
auto iter = heap.m_freed_chunks.begin();
advance(iter, i);
if (chunk->m_size > size)
@ -373,14 +374,16 @@ namespace GC
{
std::vector<Chunk *> filtered;
size_t i = 0;
auto prev = Heap::get_at(heap.m_freed_chunks, i++);
// auto prev = Heap::get_at(heap.m_freed_chunks, i++);
auto prev = heap.m_freed_chunks[i++];
prev->m_marked = true;
filtered.push_back(prev);
cout << filtered.back()->m_start << endl;
for (; i < heap.m_freed_chunks.size(); i++)
{
prev = filtered.back();
auto next = Heap::get_at(heap.m_freed_chunks, i);
// auto next = Heap::get_at(heap.m_freed_chunks, i);
auto next = heap.m_freed_chunks[i];
auto p_start = (uintptr_t)(prev->m_start);
auto p_size = (uintptr_t)(prev->m_size);
auto n_start = (uintptr_t)(next->m_start);