mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests/valgrind: add skipped fn_with_return_should_free_local_vars.vv (-autofree)
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
fn many_strings() []string {
|
||||||
|
mut res := []string{}
|
||||||
|
for i in 0..10000 { res << '${i:05}' }
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
fn abc() int {
|
||||||
|
x := many_strings()
|
||||||
|
n := x.len
|
||||||
|
// NB: the local `x` is no longer used
|
||||||
|
// it should be freed *before* the return
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
for i in 0..5 {
|
||||||
|
nstrings := abc()
|
||||||
|
eprintln('nstrings ${i:10}: $nstrings')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ const (
|
|||||||
skip_valgrind_files = [
|
skip_valgrind_files = [
|
||||||
'vlib/v/tests/valgrind/struct_field.vv',
|
'vlib/v/tests/valgrind/struct_field.vv',
|
||||||
'vlib/v/tests/valgrind/fn_returning_string_param.vv',
|
'vlib/v/tests/valgrind/fn_returning_string_param.vv',
|
||||||
|
'vlib/v/tests/valgrind/fn_with_return_should_free_local_vars.vv',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user