aboutsummaryrefslogtreecommitdiff
path: root/stdlib/rng.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-19 15:16:33 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-19 15:16:33 -0500
commit221f4ad7ea257d7d65598e89799cb389d6d5932d (patch)
tree03752fbc6042c3241f6fde70eb843e60e6b7bf7a /stdlib/rng.c
parent88d1bde371ba6bec42952f7cce242afd41f524d9 (diff)
Default RNG now uses static, thread-local memory instead of heap
allocated
Diffstat (limited to 'stdlib/rng.c')
-rw-r--r--stdlib/rng.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stdlib/rng.c b/stdlib/rng.c
index c6bcfa5d..8e98aa8e 100644
--- a/stdlib/rng.c
+++ b/stdlib/rng.c
@@ -18,14 +18,14 @@
#include "chacha.h"
-public RNG_t default_rng = NULL;
-
struct RNGState_t {
chacha_ctx chacha;
size_t unused_bytes;
uint8_t random_bytes[1024];
};
+public _Thread_local RNG_t default_rng = (struct RNGState_t[1]){};
+
PUREFUNC static Text_t RNG$as_text(const void *rng, bool colorize, const TypeInfo_t*)
{
if (!rng) return Text("RNG");