mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
valgrind: update the test
This commit is contained in:
parent
3f328a0242
commit
cf8776ac71
@ -1,18 +1,21 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
fn return_array(array_arg []string) []int {
|
fn return_array(array_arg []string) []int { // array argument must not be freed
|
||||||
s := [1, 2, 3] // escaping array must not be freed
|
s := [1, 2, 3] // escaping array must not be freed
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo() {
|
fn foo() {
|
||||||
nums := [1, 2, 3] // local array must be freed
|
nums := [1, 2, 3] // local array must be freed
|
||||||
println(nums)
|
nums_copy := nums // array assignments call .clone()
|
||||||
|
println(nums)
|
||||||
|
println(nums_copy)
|
||||||
|
nums.free()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println('start')
|
println('start')
|
||||||
foo()
|
foo()
|
||||||
println('end')
|
println('end')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user