From 219a764a83e406073dca17024aee66e56f54db53 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 18 Sep 2021 06:32:25 +0300 Subject: [PATCH] autofree: only free user reference types --- vlib/v/gen/c/cgen.v | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 8b41e4d237..99d8a7680b 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3243,7 +3243,8 @@ 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_real_pointer() { + } else if v.typ.is_ptr() && sym.name.after('.')[0].is_capital() { + // Free user reference types g.autofree_var_call('free', v) } }