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

cgen: minor fixes

This commit is contained in:
Alexander Medvednikov
2020-03-18 16:47:37 +01:00
parent c514f0b672
commit fe6707b26d
4 changed files with 8 additions and 7 deletions

View File

@ -338,7 +338,7 @@ pub fn (a array) reverse() array {
data: vcalloc(a.cap * a.element_size)
}
for i in 0..a.len {
C.memcpy(arr.data + i * arr.element_size, &a[a.len - 1 - i], arr.element_size)
C.memcpy(arr.data + i * arr.element_size, &a.data[a.len - 1 - i], arr.element_size)
}
return arr
}
@ -412,7 +412,7 @@ pub fn (b []byte) hex() string {
mut hex := malloc(b.len * 2 + 1)
mut dst_i := 0
for i in b {
n0 := i >> 4
n0 := i >> 4
hex[dst_i++] = if n0 < 10 { n0 + `0` } else { n0 + 87 }
n1 := i & 0xF
hex[dst_i++] = if n1 < 10 { n1 + `0` } else { n1 + 87 }

View File

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