improved Bytearray:fill method

This commit is contained in:
RomanDonw 2026-08-03 22:45:48 +10:00
parent 3eac247a69
commit 2c72d33485

View file

@ -142,8 +142,13 @@ local function clear(self)
self.size = 0 self.size = 0
end end
local function fill(self, byte) local function fill(self, index, size, byte)
if self.size > 0 then if index ~= nil and size ~= nil and size > 0 then
if index < 1 or index + size - 1 > self.size then
error("selected fill range is out of array bounds")
end
FFI.fill(self.bytes + index - 1, size, byte)
else
FFI.fill(self.bytes, self.size, byte) FFI.fill(self.bytes, self.size, byte)
end end
end end