mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
use runtime.random_generator_read_bytes in read procedure instead of filling it manually.
This commit is contained in:
@@ -508,18 +508,8 @@ Possible Output:
|
|||||||
*/
|
*/
|
||||||
@(require_results)
|
@(require_results)
|
||||||
read :: proc(p: []byte, gen := context.random_generator) -> (n: int) {
|
read :: proc(p: []byte, gen := context.random_generator) -> (n: int) {
|
||||||
pos := i8(0)
|
if !runtime.random_generator_read_bytes(gen, p) {return 0}
|
||||||
val := i64(0)
|
return len(p)
|
||||||
for n = 0; n < len(p); n += 1 {
|
|
||||||
if pos == 0 {
|
|
||||||
val = int63(gen)
|
|
||||||
pos = 7
|
|
||||||
}
|
|
||||||
p[n] = byte(val)
|
|
||||||
val >>= 8
|
|
||||||
pos -= 1
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user