mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
prealloc: use u8 instead of byte
This commit is contained in:
parent
3f62487409
commit
f22ba836fd
@ -22,7 +22,7 @@ struct VMemoryBlock {
|
|||||||
mut:
|
mut:
|
||||||
id int
|
id int
|
||||||
cap isize
|
cap isize
|
||||||
start &byte = 0
|
start &u8 = 0
|
||||||
previous &VMemoryBlock = 0
|
previous &VMemoryBlock = 0
|
||||||
remaining isize
|
remaining isize
|
||||||
current &u8 = 0
|
current &u8 = 0
|
||||||
@ -46,7 +46,7 @@ fn vmemory_block_new(prev &VMemoryBlock, at_least isize) &VMemoryBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[unsafe]
|
[unsafe]
|
||||||
fn vmemory_block_malloc(n isize) &byte {
|
fn vmemory_block_malloc(n isize) &u8 {
|
||||||
unsafe {
|
unsafe {
|
||||||
if g_memory_block.remaining < n {
|
if g_memory_block.remaining < n {
|
||||||
g_memory_block = vmemory_block_new(g_memory_block, n)
|
g_memory_block = vmemory_block_new(g_memory_block, n)
|
||||||
@ -96,12 +96,12 @@ fn prealloc_vcleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[unsafe]
|
[unsafe]
|
||||||
fn prealloc_malloc(n isize) &byte {
|
fn prealloc_malloc(n isize) &u8 {
|
||||||
return unsafe { vmemory_block_malloc(n) }
|
return unsafe { vmemory_block_malloc(n) }
|
||||||
}
|
}
|
||||||
|
|
||||||
[unsafe]
|
[unsafe]
|
||||||
fn prealloc_realloc(old_data &byte, old_size isize, new_size isize) &byte {
|
fn prealloc_realloc(old_data &u8, old_size isize, new_size isize) &u8 {
|
||||||
new_ptr := unsafe { vmemory_block_malloc(new_size) }
|
new_ptr := unsafe { vmemory_block_malloc(new_size) }
|
||||||
min_size := if old_size < new_size { old_size } else { new_size }
|
min_size := if old_size < new_size { old_size } else { new_size }
|
||||||
unsafe { C.memcpy(new_ptr, old_data, min_size) }
|
unsafe { C.memcpy(new_ptr, old_data, min_size) }
|
||||||
@ -109,7 +109,7 @@ fn prealloc_realloc(old_data &byte, old_size isize, new_size isize) &byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[unsafe]
|
[unsafe]
|
||||||
fn prealloc_calloc(n isize) &byte {
|
fn prealloc_calloc(n isize) &u8 {
|
||||||
new_ptr := unsafe { vmemory_block_malloc(n) }
|
new_ptr := unsafe { vmemory_block_malloc(n) }
|
||||||
unsafe { C.memset(new_ptr, 0, n) }
|
unsafe { C.memset(new_ptr, 0, n) }
|
||||||
return new_ptr
|
return new_ptr
|
||||||
|
Loading…
Reference in New Issue
Block a user