about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-07-09 15:05:43 -0700
committerBrian Anderson <banderson@mozilla.com>2013-07-09 15:05:43 -0700
commit2c1315719da842b8d5fcd5e59faf58f2bb408765 (patch)
tree8491ccd26b529e2c3448e76a9282fab829557c86 /src/rt/rust_builtin.cpp
parent07e52eb7fc75466d294a1fd9d614f5e0276ab834 (diff)
downloadrust-2c1315719da842b8d5fcd5e59faf58f2bb408765.tar.gz
rust-2c1315719da842b8d5fcd5e59faf58f2bb408765.zip
rt: Make the old rand builtins work with newsched
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index caa2b53b3db..4a5fcf3c604 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -86,15 +86,10 @@ rand_gen_seed(uint8_t* dest, size_t size) {
 
 extern "C" CDECL void *
 rand_new_seeded(uint8_t* seed, size_t seed_size) {
-    rust_task *task = rust_get_current_task();
-    rust_rng *rng = (rust_rng *) task->malloc(sizeof(rust_rng),
-                                              "rand_new_seeded");
-    if (!rng) {
-        task->fail();
-        return NULL;
-    }
-    char *env_seed = task->kernel->env->rust_seed;
-    rng_init(rng, env_seed, seed, seed_size);
+    assert(seed != NULL);
+    rust_rng *rng = (rust_rng *) malloc(sizeof(rust_rng));
+    assert(rng != NULL && "rng alloc failed");
+    rng_init(rng, NULL, seed, seed_size);
     return rng;
 }
 
@@ -105,8 +100,7 @@ rand_next(rust_rng *rng) {
 
 extern "C" CDECL void
 rand_free(rust_rng *rng) {
-    rust_task *task = rust_get_current_task();
-    task->free(rng);
+    free(rng);
 }