mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
builtin: free all elements in a []string
with -autofree too
This commit is contained in:
parent
d4e16b6ddd
commit
00651c8deb
2 changed files with 16 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue