aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-11-24 01:02:34 +0100
committerpacien2018-11-24 01:02:34 +0100
commit55c305c13850190776d84b593e305bf070a7db0e (patch)
tree1c5062d495bd4bedcc809652766f23e799a7075e /src
parent0a9579c37894d67d721710a13ecc8250cf702256 (diff)
downloadgziplike-55c305c13850190776d84b593e305bf070a7db0e.tar.gz
Adapt max rawblock length to size field
Diffstat (limited to 'src')
-rw-r--r--src/rawblock.nim6
1 files 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 @@
16 16
17import integers, bitreader, bitwriter 17import integers, bitreader, bitwriter
18 18
19const maxDataBitLength = 100_000_000 * wordBitLength # 100MB 19const maxDataBitLength = high(uint16).int - 1
20const bitLengthFieldBitLength = 2 * wordBitLength 20const bitLengthFieldBitLength = 2 * wordBitLength
21 21
22type RawBlock* = object 22type RawBlock* = object
@@ -25,7 +25,7 @@ type RawBlock* = object
25 25
26proc readSerialised*(bitReader: BitReader): RawBlock = 26proc readSerialised*(bitReader: BitReader): RawBlock =
27 let bitLength = bitReader.readBits(bitLengthFieldBitLength, uint16).int 27 let bitLength = bitReader.readBits(bitLengthFieldBitLength, uint16).int
28 let data = readSeq(bitReader, bitLength, uint8) 28 let data = bitReader.readSeq(bitLength, uint8)
29 RawBlock(bitLength: bitLength, data: data.data) 29 RawBlock(bitLength: bitLength, data: data.data)
30 30
31proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) = 31proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) =
@@ -33,7 +33,7 @@ proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) =
33 bitWriter.writeSeq(rawBlock.bitLength, rawBlock.data) 33 bitWriter.writeSeq(rawBlock.bitLength, rawBlock.data)
34 34
35proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock = 35proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock =
36 let data = readSeq(bitReader, bits, uint8) 36 let data = bitReader.readSeq(bits, uint8)
37 RawBlock(bitLength: data.bitLength, data: data.data) 37 RawBlock(bitLength: data.bitLength, data: data.data)
38 38
39proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) = 39proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) =