allocator: Fix find_free() returning a block past the end when full #125

Merged
vitalif merged 1 commits from koolkhel/vitastor:allocator-full-small into master 2026-11-17 23:37:01 +03:00
2 changed files with 5 additions and 1 deletions

View File

@@ -44,5 +44,8 @@ int main(int narg, char *args[])
alloc_all(8192);
alloc_all(8062);
alloc_all(4096);
alloc_all(64);
alloc_all(63);
alloc_all(2);
return 0;
}

View File

@@ -135,7 +135,8 @@ uint64_t allocator_t::find_free()
offset += p2;
p2 = p2 * 64;
}
return addr;
// A full single-level mask (size < 64) still has zero bits past the end
return addr < size ? addr : UINT64_MAX;
}
uint64_t allocator_t::get_free_count()