1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: free all elements in a []string with -autofree too

This commit is contained in:
Delyan Angelov
2021-03-18 21:10:42 +02:00
parent d4e16b6ddd
commit 00651c8deb
2 changed files with 16 additions and 0 deletions

View File

@@ -485,6 +485,17 @@ pub fn (a &array) free() {
C.free(a.data)
}
[unsafe]
pub fn (mut a []string) free() {
$if prealloc {
return
}
for s in a {
unsafe { s.free() }
}
C.free(a.data)
}
// str returns a string representation of the array of strings
// => '["a", "b", "c"]'.
pub fn (a []string) str() string {