summaryrefslogtreecommitdiff
path: root/Kernel/Random.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-08-24 19:35:19 -0600
committerAndreas Kling <kling@serenityos.org>2020-08-25 09:48:48 +0200
commitd89582880ed81c38df67687eadfc0764b6ce5ddd (patch)
tree3ff52c4e8808c5167ee37d5bf0a6669e9a18dfb4 /Kernel/Random.cpp
parentba6e4fb77f00587d2bd57865a00b1a4526684741 (diff)
downloadserenity-d89582880ed81c38df67687eadfc0764b6ce5ddd.zip
Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
Diffstat (limited to 'Kernel/Random.cpp')
-rw-r--r--Kernel/Random.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Kernel/Random.cpp b/Kernel/Random.cpp
index f024865a74..d8fe3469cd 100644
--- a/Kernel/Random.cpp
+++ b/Kernel/Random.cpp
@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <AK/Singleton.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Devices/RandomDevice.h>
#include <Kernel/Random.h>
@@ -32,13 +33,10 @@
namespace Kernel {
-static KernelRng* s_the;
+static AK::Singleton<KernelRng> s_the;
KernelRng& KernelRng::the()
{
- if (!s_the) {
- s_the = new KernelRng;
- }
return *s_the;
}