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

autofree: only free user reference types

This commit is contained in:
Alexander Medvednikov 2021-09-18 06:32:25 +03:00
parent 6d47dd22df
commit 219a764a83

View File

@ -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)
}
}