mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
fix IB in fifoToOwnedArrayList
memcpy requires non-overlapping arguments. fifo.realign() handles this case correctly and tries to provide an optimized implementation. This probably wasn't hit in practice, as, in a typical usage, fifo's head is not advanced.
This commit is contained in:
parent
c062c532d7
commit
ffd071f558
@ -316,9 +316,7 @@ pub const RunResult = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn fifoToOwnedArrayList(fifo: *std.io.PollFifo) std.ArrayList(u8) {
|
fn fifoToOwnedArrayList(fifo: *std.io.PollFifo) std.ArrayList(u8) {
|
||||||
if (fifo.head > 0) {
|
if (fifo.head != 0) fifo.realign();
|
||||||
@memcpy(fifo.buf[0..fifo.count], fifo.buf[fifo.head..][0..fifo.count]);
|
|
||||||
}
|
|
||||||
const result = std.ArrayList(u8){
|
const result = std.ArrayList(u8){
|
||||||
.items = fifo.buf[0..fifo.count],
|
.items = fifo.buf[0..fifo.count],
|
||||||
.capacity = fifo.buf.len,
|
.capacity = fifo.buf.len,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user