mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: -autofree flag
This commit is contained in:
parent
079dcd1fff
commit
3d2c266980
@ -98,6 +98,7 @@ mut:
|
||||
// You can also quote several options at the same time: -cflags '-Os -fno-inline-small-functions'.
|
||||
ccompiler string // the name of the used C compiler
|
||||
building_v bool
|
||||
autofree bool
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -803,6 +804,7 @@ fn new_v(args[]string) &V {
|
||||
show_c_cmd: '-show_c_cmd' in args
|
||||
translated: 'translated' in args
|
||||
is_run: 'run' in args
|
||||
autofree: 'autofree' in args
|
||||
is_repl: is_repl
|
||||
build_mode: build_mode
|
||||
cflags: cflags
|
||||
|
@ -1067,9 +1067,8 @@ fn (p mut Parser) close_scope() {
|
||||
// println('breaking. "$v.name" v.scope_level=$v.scope_level')
|
||||
break
|
||||
}
|
||||
// Clean up memory, only do this for V compiler for now
|
||||
//if p.os != .windows {
|
||||
if p.pref.building_v && v.is_alloc && !p.pref.is_test {
|
||||
// Clean up memory, only do this if -autofree was passed for now
|
||||
if p.pref.autofree && v.is_alloc && !p.pref.is_test {
|
||||
mut free_fn := 'free'
|
||||
if v.typ.starts_with('array_') {
|
||||
free_fn = 'v_array_free'
|
||||
@ -1092,7 +1091,6 @@ fn (p mut Parser) close_scope() {
|
||||
} else {
|
||||
p.genln('$free_fn($v.name); // close_scope free')
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
if p.cur_fn.defer_text.last() != '' {
|
||||
|
Loading…
Reference in New Issue
Block a user