PageAllocatorEntryCount
Description
Live mapped-region count. The number of PageEntry descriptors currently tracking an OS mapping handed out by this allocator and not yet freed. Retained (user-freed but not yet returned to the OS) regions live in free_entries[] and are NOT counted here. Useful for sizing decisions and for tests that need to observe alloc / free behaviour.
Usage example (Cross-references)
Usage examples (Cross-references)
size page = PageAllocatorPageSize(&alloc);
if (PageAllocatorEntryCount(&alloc) != 0) {
WriteFmt("init EntryCount != 0\n");
ok = false; ok = false;
}
if (PageAllocatorEntryCount(&alloc) != 2) {
WriteFmt("after 2 allocs EntryCount={} want 2\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false; }
if (PageAllocatorEntryCount(&alloc) != 2) {
WriteFmt("after 2 allocs EntryCount={} want 2\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false;
} }
// EntryCount drops to 1 (p1 moved to free_entries[]).
if (PageAllocatorEntryCount(&alloc) != 1) {
WriteFmt("after free p1 EntryCount={} want 1\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false; // EntryCount drops to 1 (p1 moved to free_entries[]).
if (PageAllocatorEntryCount(&alloc) != 1) {
WriteFmt("after free p1 EntryCount={} want 1\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false;
} AllocatorFree(&alloc, p2);
}
if (PageAllocatorEntryCount(&alloc) != 0) {
WriteFmt("after free p2 EntryCount={} want 0\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false; }
if (PageAllocatorEntryCount(&alloc) != 0) {
WriteFmt("after free p2 EntryCount={} want 0\n", (u64)PageAllocatorEntryCount(&alloc));
ok = false;
} PageAllocatorDeinit(&alloc);
// Post-deinit the struct is zeroed: both accessors return 0.
if (PageAllocatorEntryCount(&alloc) != 0) {
WriteFmt("post-deinit EntryCount != 0\n");
ok = false;
Last updated on