Extract multilist_alloc_t
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Variable-length O(1) disk space allocator
|
||||
// Copyright (c) Vitaliy Filippov, 2025+
|
||||
// License: VNPL-1.1 (see README.md for details)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
struct multilist_alloc_t
|
||||
{
|
||||
const uint32_t count, maxn;
|
||||
std::vector<int32_t> sizes;
|
||||
std::vector<uint32_t> nexts, prevs, heads;
|
||||
|
||||
multilist_alloc_t(uint32_t count, uint32_t maxn);
|
||||
bool is_free(uint32_t pos);
|
||||
uint32_t find(uint32_t size);
|
||||
void use_full(uint32_t pos);
|
||||
void use(uint32_t pos, uint32_t size);
|
||||
void do_free(uint32_t pos);
|
||||
void free(uint32_t pos);
|
||||
void verify();
|
||||
void print();
|
||||
};
|
||||
Reference in New Issue
Block a user