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

fn copy(dst, src) []byte

This commit is contained in:
joe-conigliaro 2019-07-29 01:19:59 +10:00 committed by Alexander Medvednikov
parent c7edeb00a8
commit df06eee5e8

View File

@ -251,3 +251,13 @@ pub fn (b []byte) hex() string {
}
return string(hex)
}
// TODO: implement for all types
pub fn copy(dst, src []byte) int {
if dst.len > 0 && src.len > 0 {
min := if dst.len < src.len { dst.len } else { src.len }
C.memcpy(dst.data, src.left(min).data, dst.element_size*min)
return min
}
return 0
}