mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
urllib: rem underscore methods from; add strings index_bytes
This commit is contained in:

committed by
Alexander Medvednikov

parent
f3abb9e682
commit
f8fefd5a60
@ -26,22 +26,22 @@ pub fn read(bytes_needed int) ?[]byte {
|
||||
if bytes_needed > ReadBatchSize {
|
||||
no_batches := int(math.floor(f64(bytes_needed/ReadBatchSize)))
|
||||
for i:=0; i<no_batches; i++ {
|
||||
if _getrandom(ReadBatchSize, buffer+bytes_read) == -1 {
|
||||
if getrandom(ReadBatchSize, buffer+bytes_read) == -1 {
|
||||
return ReadError
|
||||
}
|
||||
bytes_read += ReadBatchSize
|
||||
}
|
||||
}
|
||||
if _getrandom(bytes_needed-bytes_read, buffer+bytes_read) == -1 {
|
||||
if getrandom(bytes_needed-bytes_read, buffer+bytes_read) == -1 {
|
||||
return ReadError
|
||||
}
|
||||
|
||||
return c_array_to_bytes_tmp(bytes_needed, buffer)
|
||||
}
|
||||
|
||||
fn _getrandom(bytes_needed int, buffer voidptr) int {
|
||||
fn getrandom(bytes_needed int, buffer voidptr) int {
|
||||
if bytes_needed > ReadBatchSize {
|
||||
panic('_getrandom() dont request more thane $ReadBatchSize bytes at once.')
|
||||
panic('getrandom() dont request more thane $ReadBatchSize bytes at once.')
|
||||
}
|
||||
return C.syscall(C.SYS_getrandom, buffer, bytes_needed, 0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user