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

Revert "gc: extend optimized mode to strings (#10409)"

This reverts commit 3f654a69e3.
This commit is contained in:
Alexander Medvednikov
2021-06-12 01:52:06 +03:00
parent 3f654a69e3
commit e02d1d4a4b
2 changed files with 15 additions and 84 deletions

View File

@ -256,59 +256,6 @@ pub fn malloc(n int) &byte {
return res
}
[unsafe]
pub fn malloc_noscan(n int) &byte {
if n <= 0 {
panic('> V malloc(<=0)')
}
$if vplayground ? {
if n > 10000 {
panic('allocating more than 10 KB at once is not allowed in the V playground')
}
if total_m > 50 * 1024 * 1024 {
panic('allocating more than 50 MB is not allowed in the V playground')
}
}
$if trace_malloc ? {
total_m += n
C.fprintf(C.stderr, c'v_malloc %6d total %10d\n', n, total_m)
// print_backtrace()
}
mut res := &byte(0)
$if prealloc {
return unsafe { prealloc_malloc(n) }
} $else $if gcboehm ? {
$if gcboehm_opt ? {
unsafe {
res = C.GC_MALLOC_ATOMIC(n)
}
} $else {
unsafe {
res = C.GC_MALLOC(n)
}
}
} $else $if freestanding {
mut e := Errno{}
res, e = mm_alloc(u64(n))
if e != .enoerror {
eprint('malloc() failed: ')
eprintln(e.str())
panic('malloc() failed')
}
} $else {
res = unsafe { C.malloc(n) }
}
if res == 0 {
panic('malloc($n) failed')
}
$if debug_malloc ? {
// Fill in the memory with something != 0, so it is easier to spot
// when the calling code wrongly relies on it being zeroed.
unsafe { C.memset(res, 0x88, n) }
}
return res
}
// v_realloc resizes the memory block `b` with `n` bytes.
// The `b byteptr` must be a pointer to an existing memory block
// previously allocated with `malloc`, `v_calloc` or `vcalloc`.
@ -422,11 +369,7 @@ pub fn vcalloc_noscan(n int) &byte {
if n < 0 {
panic('calloc(<0)')
}
return $if gcboehm_opt ? {
unsafe { &byte(C.memset(C.GC_MALLOC_ATOMIC(n), 0, n)) }
} $else {
unsafe { &byte(C.GC_MALLOC(n)) }
}
return unsafe { &byte(C.memset(C.GC_MALLOC_ATOMIC(n), 0, n)) }
} $else {
return unsafe { vcalloc(n) }
}