From 91d865795933136fa57fe7fdceffddd1b6c49084 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 1 May 2021 12:25:51 -0700 Subject: fixup! hle: kernel: Add initial impl. of slab setup. --- src/core/hle/kernel/init/init_slab_setup.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel/init/init_slab_setup.cpp') diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp index 04e481a0a..3aa76ee33 100644 --- a/src/core/hle/kernel/init/init_slab_setup.cpp +++ b/src/core/hle/kernel/init/init_slab_setup.cpp @@ -146,21 +146,21 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { VAddr address = memory_layout.GetSlabRegionAddress(); // Initialize slab type array to be in sorted order. - KSlabType slab_types[KSlabType_Count]; - for (size_t i = 0; i < Common::Size(slab_types); i++) { + std::array slab_types; + for (size_t i = 0; i < slab_types.size(); i++) { slab_types[i] = static_cast(i); } // N shuffles the slab type array with the following simple algorithm. - for (size_t i = 0; i < Common::Size(slab_types); i++) { - const size_t rnd = KSystemControl::GenerateRandomRange(0, Common::Size(slab_types) - 1); + for (size_t i = 0; i < slab_types.size(); i++) { + const size_t rnd = KSystemControl::GenerateRandomRange(0, slab_types.size() - 1); std::swap(slab_types[i], slab_types[rnd]); } // Create an array to represent the gaps between the slabs. const size_t total_gap_size = CalculateSlabHeapGapSize(); - size_t slab_gaps[Common::Size(slab_types)]; - for (size_t i = 0; i < Common::Size(slab_gaps); i++) { + std::array slab_gaps; + for (size_t i = 0; i < slab_gaps.size(); i++) { // Note: This is an off-by-one error from Nintendo's intention, because GenerateRandomRange // is inclusive. However, Nintendo also has the off-by-one error, and it's "harmless", so we // will include it ourselves. @@ -169,13 +169,13 @@ void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { // Sort the array, so that we can treat differences between values as offsets to the starts of // slabs. - for (size_t i = 1; i < Common::Size(slab_gaps); i++) { + for (size_t i = 1; i < slab_gaps.size(); i++) { for (size_t j = i; j > 0 && slab_gaps[j - 1] > slab_gaps[j]; j--) { std::swap(slab_gaps[j], slab_gaps[j - 1]); } } - for (size_t i = 0; i < Common::Size(slab_types); i++) { + for (size_t i = 0; i < slab_types.size(); i++) { // Add the random gap to the address. address += (i == 0) ? slab_gaps[0] : slab_gaps[i] - slab_gaps[i - 1]; -- cgit v1.2.3