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

builtin: use 0 instead of \0 rune when setting C style terminators; use C.memcpy in []string{}.join("")

This commit is contained in:
Delyan Angelov
2021-04-13 11:29:33 +03:00
parent 1b924fcf41
commit a1121d0eb0
4 changed files with 25 additions and 30 deletions

View File

@ -34,7 +34,7 @@ fn (s string) add(a string) string {
for j in 0 .. a.len {
res[s.len + j] = a[j]
}
res[new_len] = `\0` // V strings are not null terminated, but just in case
res[new_len] = 0 // V strings are not null terminated, but just in case
return res
}
@ -145,6 +145,6 @@ pub fn (a string) clone() string {
str: malloc(a.len + 1)
}
mem_copy(b.str, a.str, a.len)
b[a.len] = `\0`
b[a.len] = 0
return b
}