autofree: only free user reference types

pull/11530/head
Alexander Medvednikov 2021-09-18 06:32:25 +03:00
parent 6d47dd22df
commit 219a764a83
1 changed files with 2 additions and 1 deletions

View File

@ -3243,7 +3243,8 @@ fn (mut g Gen) autofree_variable(v ast.Var) {
} }
if sym.has_method('free') { if sym.has_method('free') {
g.autofree_var_call(c_name(sym.name) + '_free', v) 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) g.autofree_var_call('free', v)
} }
} }