mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
Use memmove in buffer/blit when needed.
This commit is contained in:
parent
65ac17986a
commit
fff60b053b
@ -315,9 +315,13 @@ static Janet cfun_buffer_blit(int32_t argc, Janet *argv) {
|
||||
if (last > INT32_MAX)
|
||||
janet_panic("buffer blit out of range");
|
||||
janet_buffer_ensure(dest, (int32_t) last, 2);
|
||||
if (same_buf) src.bytes = dest->data;
|
||||
if (last > dest->count) dest->count = (int32_t) last;
|
||||
memcpy(dest->data + offset_dest, src.bytes + offset_src, length_src);
|
||||
if (same_buf) {
|
||||
src.bytes = dest->data;
|
||||
memmove(dest->data + offset_dest, src.bytes + offset_src, length_src);
|
||||
} else {
|
||||
memcpy(dest->data + offset_dest, src.bytes + offset_src, length_src);
|
||||
}
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user