From 7b60367512490618f826ccec53927bb7c76cc346 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 23 Sep 2021 04:35:09 +0300 Subject: [PATCH] autofree: free reference types with -experimental for now --- vlib/v/gen/c/cgen.v | 2 +- vlib/v/tests/valgrind/valgrind_test.v | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 9f1ff6e164..a5a48fcb77 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3246,7 +3246,7 @@ fn (mut g Gen) autofree_variable(v ast.Var) { } if sym.has_method('free') { g.autofree_var_call(c_name(sym.name) + '_free', v) - } else if v.typ.is_ptr() && sym.name.after('.')[0].is_capital() { + } else if g.pref.experimental && v.typ.is_ptr() && sym.name.after('.')[0].is_capital() { // Free user reference types g.autofree_var_call('free', v) } diff --git a/vlib/v/tests/valgrind/valgrind_test.v b/vlib/v/tests/valgrind/valgrind_test.v index fc18276222..410b5138de 100644 --- a/vlib/v/tests/valgrind/valgrind_test.v +++ b/vlib/v/tests/valgrind/valgrind_test.v @@ -74,7 +74,7 @@ fn test_all() { // exe_filename := '$wrkdir/x' full_path_to_source_file := os.join_path(vroot, test) - compile_cmd := '$vexe -o $exe_filename -cg -cflags "-w" -autofree "$full_path_to_source_file"' + compile_cmd := '$vexe -o $exe_filename -cg -cflags "-w" -experimental -autofree "$full_path_to_source_file"' vprintln('compile cmd: ${bold(compile_cmd)}') res := os.execute(compile_cmd) if res.exit_code != 0 {