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

builtin: fix -d debug_realloc, add realloc_data/3

This commit is contained in:
Delyan Angelov
2021-03-14 14:54:35 +02:00
parent ddbe57e00a
commit 125be84e3d
4 changed files with 59 additions and 27 deletions

View File

@ -445,6 +445,7 @@ pub fn get_raw_stdin() []byte {
$if windows {
unsafe {
block_bytes := 512
mut old_size := block_bytes
mut buf := malloc(block_bytes)
h_input := C.GetStdHandle(C.STD_INPUT_HANDLE)
mut bytes_read := 0
@ -456,7 +457,9 @@ pub fn get_raw_stdin() []byte {
if !res {
break
}
buf = v_realloc(buf, offset + block_bytes + (block_bytes - bytes_read))
new_size := offset + block_bytes + (block_bytes - bytes_read)
buf = realloc_data(buf, old_size, new_size)
old_size = new_size
}
return array{
element_size: 1