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

builtin: use malloc_noscan more (for map metas and in []byte.hex())

This commit is contained in:
Delyan Angelov 2022-03-11 11:07:00 +02:00
parent 1993bf2a12
commit 8dc4b1d9a3
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 4 additions and 4 deletions

View File

@ -791,7 +791,7 @@ pub fn (a []string) str() string {
// hex returns a string with the hexadecimal representation
// of the byte elements of the array.
pub fn (b []byte) hex() string {
mut hex := unsafe { malloc(b.len * 2 + 1) }
mut hex := unsafe { malloc_noscan(b.len * 2 + 1) }
mut dst_i := 0
for i in b {
n0 := i >> 4

View File

@ -324,7 +324,7 @@ pub fn malloc_noscan(n int) &byte {
}
$if trace_malloc ? {
total_m += n
C.fprintf(C.stderr, c'_v_malloc %6d total %10d\n', n, total_m)
C.fprintf(C.stderr, c'malloc_noscan %6d total %10d\n', n, total_m)
// print_backtrace()
}
mut res := &byte(0)

View File

@ -662,7 +662,7 @@ pub fn (m &map) clone() map {
cached_hashbits: m.cached_hashbits
shift: m.shift
key_values: unsafe { m.key_values.clone() }
metas: unsafe { &u32(malloc(metasize)) }
metas: unsafe { &u32(malloc_noscan(metasize)) }
extra_metas: m.extra_metas
len: m.len
has_string_keys: m.has_string_keys

View File

@ -18,7 +18,7 @@ pub fn (c rune) str() string {
println('len=$len')
mut str := string{
len: len
str: malloc(len + 1)
str: malloc_noscan(len + 1)
}
for i in 0..len {
str.str[i] = byte(int(c)>>8 * (3 - i) & 0xff)