summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-07-12 23:18:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-07-14 13:04:41 +0200
commit2a597bdcfcb6fd685be121d7f52693832c122589 (patch)
treec142767cd96672eba3891ac34be4ee065ec60640
parent19abcac32009d58450d80add39c5b1d5e7d8a993 (diff)
w
-rw-r--r--src/handle-page.inl1
-rw-r--r--test/handle.cpp16
2 files changed, 14 insertions, 3 deletions
diff --git a/src/handle-page.inl b/src/handle-page.inl
index 09d351ac..fbd28043 100644
--- a/src/handle-page.inl
+++ b/src/handle-page.inl
@@ -56,6 +56,7 @@ void Page<Obj, PageSize>::deallocate(Handle<Obj, PageSize> obj)
fm_assert(obj.counter == ctr);
item.next = first_free;
used_count--;
+ used_map.set(index, false);
first_free = obj.index;
}
diff --git a/test/handle.cpp b/test/handle.cpp
index 2198281c..cbec8cac 100644
--- a/test/handle.cpp
+++ b/test/handle.cpp
@@ -32,9 +32,19 @@ namespace {
void test_page1()
{
Page page{start_index};
- auto& item = page.allocate();
- fm_assert(item.handle == Handle{start_index});
- page.deallocate(item.handle);
+ auto& item0 = page.allocate();
+ auto handle0 = item0.handle;
+ fm_assert(item0.handle == Handle{start_index});
+ page.deallocate(item0.handle);
+
+ auto& item1 = page.allocate();
+ auto& item2 = page.allocate();
+ fm_assert(item1.handle.index == start_index || item2.handle.index == start_index);
+ fm_assert(item1.handle.index != item2.handle.index);
+ fm_assert(item1.handle.counter != item2.handle.counter);
+ fm_assert(int{item1.handle.counter != handle0.counter} + int{item2.handle.counter != handle0.counter} == 1);
+ page.deallocate(item2.handle);
+ page.deallocate(item1.handle);
}
} // namespace