1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

remove "import const" everywhere

This commit is contained in:
Alexander Medvednikov
2019-08-23 00:00:31 +03:00
parent dcfc9eb1a1
commit f61b14584a
11 changed files with 172 additions and 308 deletions

View File

@@ -6,20 +6,10 @@ module rand
#flag darwin -framework Security
// import const (
// kSecRandomDefault
// errSecSuccess
// )
const (
kSecRandomDefault = 0
errSecSuccess = 0
)
pub fn read(bytes_needed int) ?[]byte {
mut buffer := malloc(bytes_needed)
status := C.SecRandomCopyBytes(kSecRandomDefault, bytes_needed, buffer)
if status != errSecSuccess {
status := C.SecRandomCopyBytes(0, bytes_needed, buffer)
if status != 0 {
return ReadError
}
return c_array_to_bytes_tmp(bytes_needed, buffer)