mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
strings.builder: fix a memory leak
This commit is contained in:
@ -106,7 +106,7 @@ pub fn (b mut Builder) free() {
|
|||||||
}
|
}
|
||||||
// QTODO checker bug
|
// QTODO checker bug
|
||||||
s := b.initial_size
|
s := b.initial_size
|
||||||
b.buf = []byte{cap: s}
|
//b.buf = []byte{cap: s}
|
||||||
b.len = 0
|
b.len = 0
|
||||||
b.str_calls = 0
|
b.str_calls = 0
|
||||||
}
|
}
|
||||||
|
@ -3310,7 +3310,7 @@ fn (mut g Gen) gen_str_for_array(info table.Array, styp, str_fn_name string) {
|
|||||||
g.auto_str_funcs.writeln('\t\tstring x = ${field_styp}_str(it);')
|
g.auto_str_funcs.writeln('\t\tstring x = ${field_styp}_str(it);')
|
||||||
}
|
}
|
||||||
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, x);')
|
g.auto_str_funcs.writeln('\t\tstrings__Builder_write(&sb, x);')
|
||||||
if info.elem_type != table.bool_type {
|
if g.pref.autofree && info.elem_type != table.bool_type {
|
||||||
// no need to free "true"/"false" literals
|
// no need to free "true"/"false" literals
|
||||||
g.auto_str_funcs.writeln('\t\tstring_free(x);')
|
g.auto_str_funcs.writeln('\t\tstring_free(x);')
|
||||||
}
|
}
|
||||||
@ -3319,7 +3319,10 @@ fn (mut g Gen) gen_str_for_array(info table.Array, styp, str_fn_name string) {
|
|||||||
g.auto_str_funcs.writeln('\t\t}')
|
g.auto_str_funcs.writeln('\t\t}')
|
||||||
g.auto_str_funcs.writeln('\t}')
|
g.auto_str_funcs.writeln('\t}')
|
||||||
g.auto_str_funcs.writeln('\tstrings__Builder_write(&sb, tos3("]"));')
|
g.auto_str_funcs.writeln('\tstrings__Builder_write(&sb, tos3("]"));')
|
||||||
g.auto_str_funcs.writeln('\treturn strings__Builder_str(&sb);')
|
g.auto_str_funcs.writeln('\tstring res = strings__Builder_str(&sb);')
|
||||||
|
g.auto_str_funcs.writeln('\tstrings__Builder_free(&sb);')
|
||||||
|
// g.auto_str_funcs.writeln('\treturn strings__Builder_str(&sb);')
|
||||||
|
g.auto_str_funcs.writeln('\treturn res;')
|
||||||
g.auto_str_funcs.writeln('}')
|
g.auto_str_funcs.writeln('}')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user