Skip to content

Commit 2c13157

Browse files
committed
rt: Make the old rand builtins work with newsched
1 parent 07e52eb commit 2c13157

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/rt/rust_builtin.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,10 @@ rand_gen_seed(uint8_t* dest, size_t size) {
8686

8787
extern "C" CDECL void *
8888
rand_new_seeded(uint8_t* seed, size_t seed_size) {
89-
rust_task *task = rust_get_current_task();
90-
rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng),
91-
"rand_new_seeded");
92-
if (!rng) {
93-
task->fail();
94-
return NULL;
95-
}
96-
char *env_seed = task->kernel->env->rust_seed;
97-
rng_init(rng, env_seed, seed, seed_size);
89+
assert(seed != NULL);
90+
rust_rng *rng = (rust_rng *) malloc(sizeof(rust_rng));
91+
assert(rng != NULL && "rng alloc failed");
92+
rng_init(rng, NULL, seed, seed_size);
9893
return rng;
9994
}
10095

@@ -105,8 +100,7 @@ rand_next(rust_rng *rng) {
105100

106101
extern "C" CDECL void
107102
rand_free(rust_rng *rng) {
108-
rust_task *task = rust_get_current_task();
109-
task->free(rng);
103+
free(rng);
110104
}
111105

112106

0 commit comments

Comments
 (0)