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

gen: implement a [manualfree] tag, for functions, that want to do their own memory management

This commit is contained in:
Delyan Angelov
2021-01-08 14:56:55 +02:00
parent 06bcd404b0
commit 083dc23db8
10 changed files with 77 additions and 53 deletions

View File

@@ -3,7 +3,6 @@
module gen
import v.table
import v.pref
import v.util
fn (mut g Gen) gen_str_default(sym table.TypeSymbol, styp string, str_fn_name string) {
@@ -230,7 +229,7 @@ fn (mut g Gen) gen_str_for_array(info table.Array, styp string, str_fn_name stri
}
}
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, x);')
if g.pref.autofree && typ != table.bool_type {
if g.is_autofree && typ != table.bool_type {
// no need to free "true"/"false" literals
g.auto_str_funcs.writeln('\t\tstring_free(&x);')
}