call both raw and user free on pointer vars

pull/13823/head
Daniel Oberhoff 2022-03-25 19:31:47 +01:00
parent 7193170455
commit 20106d54f5
1 changed files with 4 additions and 3 deletions

View File

@ -2638,12 +2638,13 @@ fn (mut g Gen) autofree_variable(v ast.Var) {
g.autofree_var_call('string_free', v)
return
}
if sym.has_method('free') {
g.autofree_var_call(free_fn, v)
} else if g.pref.experimental && v.typ.is_ptr() && sym.name.after('.')[0].is_capital() {
if g.pref.experimental && v.typ.is_ptr() && sym.name.after('.')[0].is_capital() {
// Free user reference types
g.autofree_var_call('free', v)
}
if sym.has_method('free') {
g.autofree_var_call(free_fn, v)
}
}
fn (mut g Gen) autofree_var_call(free_fn_name string, v ast.Var) {