From 55c305c13850190776d84b593e305bf070a7db0e Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 24 Nov 2018 01:02:34 +0100 Subject: Adapt max rawblock length to size field --- src/rawblock.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rawblock.nim b/src/rawblock.nim index e45c83f..0a44550 100644 --- a/src/rawblock.nim +++ b/src/rawblock.nim @@ -16,7 +16,7 @@ import integers, bitreader, bitwriter -const maxDataBitLength = 100_000_000 * wordBitLength # 100MB +const maxDataBitLength = high(uint16).int - 1 const bitLengthFieldBitLength = 2 * wordBitLength type RawBlock* = object @@ -25,7 +25,7 @@ type RawBlock* = object proc readSerialised*(bitReader: BitReader): RawBlock = let bitLength = bitReader.readBits(bitLengthFieldBitLength, uint16).int - let data = readSeq(bitReader, bitLength, uint8) + let data = bitReader.readSeq(bitLength, uint8) RawBlock(bitLength: bitLength, data: data.data) proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) = @@ -33,7 +33,7 @@ proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) = bitWriter.writeSeq(rawBlock.bitLength, rawBlock.data) proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock = - let data = readSeq(bitReader, bits, uint8) + let data = bitReader.readSeq(bits, uint8) RawBlock(bitLength: data.bitLength, data: data.data) proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) = -- cgit v1.2.3