mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 08:08:39 -04:00
kern: update KMemoryBlockManagerUpdaterAllocator for new ctor/init semantics
This commit is contained in:
parent
c216f92a91
commit
1fce7b08b1
2 changed files with 122 additions and 86 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue