gc: enable on macos and add leak detection fns

pull/9399/head
Alexander Medvednikov 2021-03-21 05:31:06 +03:00
parent 5873149c77
commit 4d77f3810f
2 changed files with 8 additions and 2 deletions

View File

@ -9,10 +9,16 @@ $if windows {
#include <gc.h>
#flag -lgc
#flag linux -lgc
#flag darwin @VROOT/thirdparty/bdwgc/extra/.libs/gc.o
fn C.GC_MALLOC(n size_t) voidptr
fn C.GC_REALLOC(ptr voidptr, n size_t) voidptr
fn C.GC_FREE(ptr voidptr)
fn C.GC_set_find_leak(int)
// fn C.CHECK_LEAKS()
fn C.GC_gcollect()

View File

@ -5168,7 +5168,7 @@ fn (mut g Gen) write_init_function() {
// g.writeln('g_str_buf = malloc( ${mb_size} * 1024 * 1000 );')
}
if g.pref.prealloc {
g.writeln('g_m2_buf = malloc(50 * 1000 * 1000);')
g.writeln('g_m2_buf = malloc(150 * 1000 * 1000);')
g.writeln('g_m2_ptr = g_m2_buf;')
}
// NB: the as_cast table should be *before* the other constant initialize calls,