mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix a bug in array_delete
This commit is contained in:
parent
7963e48ca1
commit
2adfbfc830
@ -148,7 +148,9 @@ pub fn (mut a array) delete(i int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
size := a.element_size
|
size := a.element_size
|
||||||
C.memmove(byteptr(a.data) + i * size, byteptr(a.data) + (i + 1) * size, (a.len - i) * size)
|
// NB: if a is [12,34], a.len = 2, a.delete(0)
|
||||||
|
// should move (2-0-1) elements = 1 element (the 34) forward
|
||||||
|
C.memmove(byteptr(a.data) + i * size, byteptr(a.data) + (i + 1) * size, (a.len - i - 1) * size)
|
||||||
a.len--
|
a.len--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user