mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-02-10 22:24:52 +00:00
fix: use new randomness api
This commit is contained in:
parent
335aaafcff
commit
551008ac19
|
|
@ -206,7 +206,7 @@ pub fn build(b: *Build) !void {
|
||||||
|
|
||||||
var prng = std.Random.DefaultPrng.init(blk: {
|
var prng = std.Random.DefaultPrng.init(blk: {
|
||||||
var seed: u64 = undefined;
|
var seed: u64 = undefined;
|
||||||
try std.posix.getrandom(std.mem.asBytes(&seed));
|
io.random(std.mem.asBytes(&seed));
|
||||||
break :blk seed;
|
break :blk seed;
|
||||||
});
|
});
|
||||||
const rnd = prng.random();
|
const rnd = prng.random();
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,11 @@ fn heal(allocator: Allocator, exercises: []const Exercise, work_path: []const u8
|
||||||
|
|
||||||
fn createTempPath(b: *Build) ![]const u8 {
|
fn createTempPath(b: *Build) ![]const u8 {
|
||||||
const io = b.graph.io;
|
const io = b.graph.io;
|
||||||
const rand_int = std.crypto.random.int(u64);
|
const rand_int = r: {
|
||||||
|
var x: u64 = undefined;
|
||||||
|
io.random(@ptrCast(&x));
|
||||||
|
break :r x;
|
||||||
|
};
|
||||||
const tmp_dir_sub_path = "tmp" ++ std.Io.Dir.path.sep_str ++ std.fmt.hex(rand_int);
|
const tmp_dir_sub_path = "tmp" ++ std.Io.Dir.path.sep_str ++ std.fmt.hex(rand_int);
|
||||||
const result_path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM");
|
const result_path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM");
|
||||||
try b.cache_root.handle.createDirPath(io, tmp_dir_sub_path);
|
try b.cache_root.handle.createDirPath(io, tmp_dir_sub_path);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user