mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: autofree: first step
This commit is contained in:
@ -42,6 +42,7 @@ pub fn make(len int, cap int, elm_size int) array {
|
||||
// Private function, used by V (`nums := [1, 2, 3]`)
|
||||
fn new_array_from_c_array(len, cap, elm_size int, c_array voidptr) array {
|
||||
cap_ := if cap == 0 { 1 } else { cap }
|
||||
|
||||
arr := array{
|
||||
len: len
|
||||
cap: cap
|
||||
@ -377,7 +378,9 @@ pub fn (a []int) str() string {
|
||||
mut sb := strings.new_builder(a.len * 13)
|
||||
sb.write('[')
|
||||
for i in 0..a.len {
|
||||
sb.write(a[i].str())
|
||||
val := a[i].str()
|
||||
sb.write(val)
|
||||
val.free()
|
||||
if i < a.len - 1 {
|
||||
sb.write(', ')
|
||||
}
|
||||
|
Reference in New Issue
Block a user