kern: update KMemoryBlockManagerUpdaterAllocator for new ctor/init semantics

This commit is contained in:
Michael Scire authored and SciresM committed 2021-04-11 03:42:16 -07:00
1 parent c216f92a91
commit 1fce7b08b1
2 files changed
+122 -86

No files matched your search

@@ -27,18 +27,8 @@ namespace ams::kern {
KMemoryBlock *m_blocks[MaxBlocks];
size_t m_index;
KMemoryBlockSlabManager *m_slab_manager;
public:
constexpr explicit KMemoryBlockManagerUpdateAllocator(KMemoryBlockSlabManager *sm) : m_blocks(), m_index(MaxBlocks), m_slab_manager(sm) { /* ... */ }
~KMemoryBlockManagerUpdateAllocator() {
for (const auto &block : m_blocks) {
if (block != nullptr) {
m_slab_manager->Free(block);
}
}
}
Result Initialize(size_t num_blocks) {
private:
ALWAYS_INLINE Result Initialize(size_t num_blocks) {
/* Check num blocks. */
MESOSPHERE_ASSERT(num_blocks <= MaxBlocks);
@@ -53,6 +43,18 @@ namespace ams::kern {
return ResultSuccess();
}
public:
KMemoryBlockManagerUpdateAllocator(Result *out_result, KMemoryBlockSlabManager *sm, size_t num_blocks = MaxBlocks) : m_blocks(), m_index(MaxBlocks), m_slab_manager(sm) {
*out_result = this->Initialize(num_blocks);
}
~KMemoryBlockManagerUpdateAllocator() {
for (const auto &block : m_blocks) {
if (block != nullptr) {
m_slab_manager->Free(block);
}
}
}
KMemoryBlock *Allocate() {
MESOSPHERE_ABORT_UNLESS(m_index < MaxBlocks);