diff options
author | pacien | 2018-11-24 01:02:34 +0100 |
---|---|---|
committer | pacien | 2018-11-24 01:02:34 +0100 |
commit | 55c305c13850190776d84b593e305bf070a7db0e (patch) | |
tree | 1c5062d495bd4bedcc809652766f23e799a7075e | |
parent | 0a9579c37894d67d721710a13ecc8250cf702256 (diff) | |
download | gziplike-55c305c13850190776d84b593e305bf070a7db0e.tar.gz |
Adapt max rawblock length to size field
-rw-r--r-- | src/rawblock.nim | 6 |
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 | ||
17 | import integers, bitreader, bitwriter | 17 | import integers, bitreader, bitwriter |
18 | 18 | ||
19 | const maxDataBitLength = 100_000_000 * wordBitLength # 100MB | 19 | const maxDataBitLength = high(uint16).int - 1 |
20 | const bitLengthFieldBitLength = 2 * wordBitLength | 20 | const bitLengthFieldBitLength = 2 * wordBitLength |
21 | 21 | ||
22 | type RawBlock* = object | 22 | type RawBlock* = object |
@@ -25,7 +25,7 @@ type RawBlock* = object | |||
25 | 25 | ||
26 | proc readSerialised*(bitReader: BitReader): RawBlock = | 26 | proc 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 | ||
31 | proc writeSerialisedTo*(rawBlock: RawBlock, bitWriter: BitWriter) = | 31 | proc 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 | ||
35 | proc readRaw*(bitReader: BitReader, bits: int = maxDataBitLength): RawBlock = | 35 | proc 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 | ||
39 | proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) = | 39 | proc writeRawTo*(rawBlock: RawBlock, bitWriter: BitWriter) = |