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

update malloc

This commit is contained in:
Alexander Medvednikov 2019-12-14 02:46:55 +03:00
parent 962109e855
commit 8581c11900
2 changed files with 5 additions and 4 deletions

View File

@ -108,20 +108,18 @@ pub fn malloc(n int) byteptr {
if n < 0 { if n < 0 {
panic('malloc(<0)') panic('malloc(<0)')
} }
/* $if prealloc {
$if debug {
res := g_m2_ptr res := g_m2_ptr
g_m2_ptr += n g_m2_ptr += n
nr_mallocs++ nr_mallocs++
return res return res
} $else { } $else {
*/
ptr := C.malloc(n) ptr := C.malloc(n)
if ptr == 0 { if ptr == 0 {
panic('malloc($n) failed') panic('malloc($n) failed')
} }
return ptr return ptr
//} }
/* /*
TODO TODO
#ifdef VPLAY #ifdef VPLAY

View File

@ -230,6 +230,9 @@ pub fn (v mut V) compile() {
cgen.genln('#define VDEBUG (1)') cgen.genln('#define VDEBUG (1)')
} }
} }
if v.pref.prealloc {
cgen.genln('#define VPREALLOC (1)')
}
if v.os == .js { if v.os == .js {
cgen.genln('#define _VJS (1) ') cgen.genln('#define _VJS (1) ')
} }