From f5ce71793e1d60fdecd641484038a1436c161905 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 21 Nov 2018 18:22:24 -0500
Subject: [PATCH 1/3] kernel/handle_table: Default destructor in the cpp file

We don't need to potentially inline the teardown logic of all of the
handle instances.
---
 src/core/hle/kernel/handle_table.cpp | 2 ++
 src/core/hle/kernel/handle_table.h   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index 5ee5c05e3..9f2b996c4 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -18,6 +18,8 @@ HandleTable::HandleTable() {
     Clear();
 }
 
+HandleTable::~HandleTable() = default;
+
 ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) {
     DEBUG_ASSERT(obj != nullptr);
 
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index 9e2f33e8a..b5e5f6545 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -43,6 +43,7 @@ enum KernelHandle : Handle {
 class HandleTable final : NonCopyable {
 public:
     HandleTable();
+    ~HandleTable();
 
     /**
      * Allocates a handle for the given object.

From 568bcbc29d099f030f7022838cd788dfe2feba45 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 21 Nov 2018 18:28:01 -0500
Subject: [PATCH 2/3] kernel/handle_table: Restrict handle table size to 1024
 entries

The previous handle table size is a holdover from Citra. The actual
handle table construct on Horizon only allows for a maximum of 1024
entries.
---
 src/core/hle/kernel/handle_table.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index b5e5f6545..ae3116afc 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -90,11 +90,8 @@ public:
     void Clear();
 
 private:
-    /**
-     * This is the maximum limit of handles allowed per process in CTR-OS. It can be further
-     * reduced by ExHeader values, but this is not emulated here.
-     */
-    static const std::size_t MAX_COUNT = 4096;
+    /// This is the maximum limit of handles allowed per process in Horizon
+    static constexpr std::size_t MAX_COUNT = 1024;
 
     static u16 GetSlot(Handle handle) {
         return handle >> 15;

From 0e35f1bb18b71fcb936b3a00e6bda0fa82a0b59c Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 21 Nov 2018 18:30:58 -0500
Subject: [PATCH 3/3] kernel/handle_table: Move private static functions into
 the cpp file

These don't depend on class state, and are effectively implementation
details, so they can go into the cpp file .
---
 src/core/hle/kernel/handle_table.cpp | 9 +++++++++
 src/core/hle/kernel/handle_table.h   | 7 -------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index 9f2b996c4..1bf79b692 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -12,6 +12,15 @@
 #include "core/hle/kernel/thread.h"
 
 namespace Kernel {
+namespace {
+constexpr u16 GetSlot(Handle handle) {
+    return handle >> 15;
+}
+
+constexpr u16 GetGeneration(Handle handle) {
+    return handle & 0x7FFF;
+}
+} // Anonymous namespace
 
 HandleTable::HandleTable() {
     next_generation = 1;
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index ae3116afc..e3f3e3fb8 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -93,13 +93,6 @@ private:
     /// This is the maximum limit of handles allowed per process in Horizon
     static constexpr std::size_t MAX_COUNT = 1024;
 
-    static u16 GetSlot(Handle handle) {
-        return handle >> 15;
-    }
-    static u16 GetGeneration(Handle handle) {
-        return handle & 0x7FFF;
-    }
-
     /// Stores the Object referenced by the handle or null if the slot is empty.
     std::array<SharedPtr<Object>, MAX_COUNT> objects;