summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-05-01 21:25:51 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:53 +0200
commit91d865795933136fa57fe7fdceffddd1b6c49084 (patch)
tree0c5be20bb3a51d21ef4ecc963b2cf0be531c3084
parentcommon: Rename NON_COPYABLE/NON_MOVABLE with YUZU_ prefix. (diff)
downloadyuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar.gz
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar.bz2
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar.lz
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar.xz
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.tar.zst
yuzu-91d865795933136fa57fe7fdceffddd1b6c49084.zip
-rw-r--r--src/core/hle/kernel/init/init_slab_setup.cpp16
1 files changed, 8 insertions, 8 deletions
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<KSlabType, KSlabType_Count> slab_types;
+ for (size_t i = 0; i < slab_types.size(); i++) {
slab_types[i] = static_cast<KSlabType>(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<size_t, slab_types.size()> 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];