diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 89c6cc6db0..25f80eaa79 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -167,7 +167,7 @@ fn (a array) get(i int) voidptr { panic('array.get: index out of range (i == $i, a.len == $a.len)') } } - return a.data + i * a.element_size + return byteptr(a.data) + i * a.element_size } // array.first returns the first element of the array @@ -177,7 +177,7 @@ pub fn (a array) first() voidptr { panic('array.first: array is empty') } } - return a.data + 0 + return a.data } // array.last returns the last element of the array @@ -187,7 +187,7 @@ pub fn (a array) last() voidptr { panic('array.last: array is empty') } } - return a.data + (a.len - 1) * a.element_size + return byteptr(a.data) + (a.len - 1) * a.element_size } /* @@ -242,7 +242,7 @@ fn (a array) slice(start, _end int) array { l := end - start res := array{ element_size: a.element_size - data: a.data + start * a.element_size + data: byteptr(a.data) + start * a.element_size len: l cap: l } @@ -267,7 +267,7 @@ pub fn (a &array) clone() array { element_size: a.element_size data: vcalloc(size) } - C.memcpy(arr.data, a.data, a.cap * a.element_size) + C.memcpy(byteptr(arr.data), a.data, a.cap * a.element_size) return arr } @@ -287,7 +287,7 @@ fn (a &array) slice_clone(start, _end int) array { l := end - start res := array{ element_size: a.element_size - data: a.data + start * a.element_size + data: byteptr(a.data) + start * a.element_size len: l cap: l } @@ -301,12 +301,12 @@ fn (a mut array) set(i int, val voidptr) { panic('array.set: index out of range (i == $i, a.len == $a.len)') } } - C.memcpy(a.data + a.element_size * i, val, a.element_size) + C.memcpy(byteptr(a.data) + a.element_size * i, val, a.element_size) } fn (a mut array) push(val voidptr) { a.ensure_cap(a.len + 1) - C.memcpy(a.data + a.element_size * a.len, val, a.element_size) + C.memcpy(byteptr(a.data) + a.element_size * a.len, val, a.element_size) a.len++ } @@ -318,10 +318,10 @@ pub fn (a3 mut array) push_many(val voidptr, size int) { copy := a3.clone() a3.ensure_cap(a3.len + size) //C.memcpy(a.data, copy.data, copy.element_size * copy.len) - C.memcpy(a3.data + a3.element_size * a3.len, copy.data, a3.element_size * size) + C.memcpy(byteptr(a3.data) + a3.element_size * a3.len, copy.data, a3.element_size * size) } else { a3.ensure_cap(a3.len + size) - C.memcpy(a3.data + a3.element_size * a3.len, val, a3.element_size * size) + C.memcpy(byteptr(a3.data) + a3.element_size * a3.len, val, a3.element_size * size) } a3.len += size } @@ -340,7 +340,7 @@ pub fn (a array) reverse() array { } 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, arr.element_size) + C.memcpy(byteptr(arr.data) + i * arr.element_size, byteptr(a.data) + (a.len - 1 - i) * arr.element_size, arr.element_size) } return arr } @@ -436,7 +436,7 @@ pub fn copy(dst, src []byte) int { if dst.len > 0 && src.len > 0 { mut min := 0 min = if dst.len < src.len { dst.len } else { src.len } - C.memcpy(dst.data, src[..min].data, dst.element_size * min) + C.memcpy(byteptr(dst.data), src[..min].data, dst.element_size * min) return min } return 0 @@ -607,7 +607,7 @@ pub fn compare_f32(a, b &f32) int { pub fn (a array) pointers() []voidptr { mut res := []voidptr for i in 0..a.len { - res << a.data + i * a.element_size + res << byteptr(a.data) + i * a.element_size } return res } diff --git a/vlib/builtin/builtin_windows.v b/vlib/builtin/builtin_windows.v index 647060ceb2..9487b1291b 100644 --- a/vlib/builtin/builtin_windows.v +++ b/vlib/builtin/builtin_windows.v @@ -84,18 +84,18 @@ $if msvc { frames := int( C.CaptureStackBackTrace(skipframes + 1, 100, backtraces, 0) ) for i:=0; i < frames; i++ { // fugly pointer arithmetics follows ... - s := *voidptr( u64(backtraces) + u64(i*sizeof(voidptr)) ) - symfa_ok := C.SymFromAddr( handle, *s, &offset, si ) + s := voidptr( u64(backtraces) + u64(i*sizeof(voidptr)) ) + symfa_ok := C.SymFromAddr( handle, s, &offset, si ) if symfa_ok == 1 { nframe := frames - i - 1 mut lineinfo := '' - symglfa_ok := C.SymGetLineFromAddr64(handle, *s, &offset, &sline64) + symglfa_ok := C.SymGetLineFromAddr64(handle, s, &offset, &sline64) if symglfa_ok == 1 { lineinfo = ' ${sline64.f_file_name}:${sline64.f_line_number}' } else { //cerr := int(C.GetLastError()) println('SymGetLineFromAddr64 failure: $cerr ') - lineinfo = ' ?? : address= $s' + lineinfo = ' ?? : address= ${&s}' } sfunc := tos3(fname) println('${nframe:-2d}: ${sfunc:-25s} $lineinfo') diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index 2c49247c4d..7d602ede56 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -175,7 +175,7 @@ fn new_map(n, value_bytes int) map { fn new_map_init(n, value_bytes int, keys &string, values voidptr) map { mut out := new_map(n, value_bytes) for i in 0 .. n { - out.set(keys[i], values + i * value_bytes) + out.set(keys[i], byteptr(values) + i * value_bytes) } return out } diff --git a/vlib/builtin/sorted_map.v b/vlib/builtin/sorted_map.v index 49db24a6c4..0ece0177f7 100644 --- a/vlib/builtin/sorted_map.v +++ b/vlib/builtin/sorted_map.v @@ -48,7 +48,7 @@ fn new_sorted_map(n, value_bytes int) SortedMap { // TODO: Remove `n` fn new_sorted_map_init(n, value_bytes int, keys &string, values voidptr) SortedMap { mut out := new_sorted_map(n, value_bytes) for i in 0 .. n { - out.set(keys[i], values + i * value_bytes) + out.set(keys[i], byteptr(values) + i * value_bytes) } return out }