Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2022 John Lloyd. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
module rand
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
fn C.arc4random_buf(p &u8, n usize)
|
||||
|
||||
// read returns an array of `bytes_needed` random bytes read from the OS.
|
||||
pub fn read(bytes_needed int) ![]u8 {
|
||||
mut buffer := unsafe { malloc_noscan(bytes_needed) }
|
||||
C.arc4random_buf(buffer, bytes_needed)
|
||||
return unsafe { buffer.vbytes(bytes_needed) }
|
||||
}
|
||||
Reference in new issue
Block a user