mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: various fixes for [heap]/auto-heap handling (#10033)
This commit is contained in:
@@ -9,7 +9,7 @@ pub fn memcpy(dest &C.void, src &C.void, n size_t) &C.void {
|
||||
dest_[i] = src_[i]
|
||||
}
|
||||
}
|
||||
return dest
|
||||
return unsafe { dest }
|
||||
}
|
||||
|
||||
[export: 'malloc']
|
||||
@@ -37,7 +37,7 @@ fn realloc(old_area &C.void, new_size size_t) &C.void {
|
||||
}
|
||||
old_size := unsafe { *(&u64(old_area - sizeof(u64))) }
|
||||
if u64(new_size) <= old_size {
|
||||
return old_area
|
||||
return unsafe { old_area }
|
||||
} else {
|
||||
new_area := unsafe { malloc(int(new_size)) }
|
||||
unsafe { memmove(new_area, old_area, size_t(old_size)) }
|
||||
@@ -54,7 +54,7 @@ fn memset(s &C.void, c int, n size_t) &C.void {
|
||||
s_[i] = char(c)
|
||||
}
|
||||
}
|
||||
return s
|
||||
return unsafe { s }
|
||||
}
|
||||
|
||||
[unsafe]
|
||||
@@ -74,7 +74,7 @@ fn memmove(dest &C.void, src &C.void, n size_t) &C.void {
|
||||
}
|
||||
}
|
||||
unsafe { free(temp_buf) }
|
||||
return dest
|
||||
return unsafe { dest }
|
||||
}
|
||||
|
||||
[export: 'calloc']
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn tos(s &byte, len int) string {
|
||||
panic('tos(): nil string')
|
||||
}
|
||||
return string{
|
||||
str: s
|
||||
str: unsafe { s }
|
||||
len: len
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ pub fn tos2(s &byte) string {
|
||||
panic('tos2: nil string')
|
||||
}
|
||||
return string{
|
||||
str: s
|
||||
str: unsafe { s }
|
||||
len: unsafe { vstrlen(s) }
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ pub fn tos_lit(s &char) string {
|
||||
[unsafe]
|
||||
pub fn (bp &byte) vstring() string {
|
||||
return string{
|
||||
str: bp
|
||||
str: unsafe { bp }
|
||||
len: unsafe { C.strlen(&char(bp)) }
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ pub fn (bp &byte) vstring() string {
|
||||
[unsafe]
|
||||
pub fn (bp &byte) vstring_with_len(len int) string {
|
||||
return string{
|
||||
str: bp
|
||||
str: unsafe { bp }
|
||||
len: len
|
||||
is_lit: 0
|
||||
}
|
||||
@@ -194,7 +194,7 @@ pub fn (cp &char) vstring_with_len(len int) string {
|
||||
[unsafe]
|
||||
pub fn (bp &byte) vstring_literal() string {
|
||||
return string{
|
||||
str: bp
|
||||
str: unsafe { bp }
|
||||
len: unsafe { C.strlen(&char(bp)) }
|
||||
is_lit: 1
|
||||
}
|
||||
@@ -205,7 +205,7 @@ pub fn (bp &byte) vstring_literal() string {
|
||||
[unsafe]
|
||||
pub fn (bp &byte) vstring_literal_with_len(len int) string {
|
||||
return string{
|
||||
str: bp
|
||||
str: unsafe { bp }
|
||||
len: len
|
||||
is_lit: 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user