Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -377,11 +377,11 @@ if OF_LIKELY (CTX.lengths == NULL) { CTX.lengths = [self allocMemoryWithSize: 19]; memset(CTX.lengths, 0, 19); } - for (uint_fast16_t i = CTX.receivedCount; + for (uint16_t i = CTX.receivedCount; i < CTX.codeLenCodesCount + 4; i++) { if OF_UNLIKELY (!tryReadBits(self, &bits, 3)) { CTX.receivedCount = i; return bytesWritten; } @@ -401,11 +401,11 @@ if OF_LIKELY (CTX.lengths == NULL) CTX.lengths = [self allocMemoryWithSize: CTX.litLenCodesCount + CTX.distCodesCount + 258]; - for (uint_fast16_t i = CTX.receivedCount; + for (uint16_t i = CTX.receivedCount; i < CTX.litLenCodesCount + CTX.distCodesCount + 258;) { uint8_t j, count; if OF_LIKELY (CTX.value == 0xFF) { if OF_UNLIKELY (!of_huffman_tree_walk(self, Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -254,17 +254,13 @@ return [[_lastEntry copy] autorelease]; } - (OFStream *)streamForReadingCurrentEntry { - OFString *method; - if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; - method = [_lastEntry method]; - return [[_lastReturnedStream retain] autorelease]; } - (void)close { @@ -453,11 +449,11 @@ _state = STATE_LITLEN_TREE; goto start; case STATE_LITLEN_TREE: while (_codesReceived < _codesCount) { if OF_UNLIKELY (_skip) { - uint_fast16_t skipCount; + uint16_t skipCount; switch (_codesLengths[_codesReceived]) { case 0: skipCount = 1; break; @@ -482,11 +478,11 @@ if OF_UNLIKELY (_codesReceived + skipCount > _codesCount) @throw [OFInvalidFormatException exception]; - for (uint16_t j = 0; j < skipCount; j++) + for (uint_fast16_t j = 0; j < skipCount; j++) _codesLengths[_codesReceived++] = 0; _skip = false; continue; } @@ -680,10 +676,12 @@ _treeIter = _litLenTree; _state = STATE_BLOCK_LITLEN; goto start; } + + OF_UNREACHABLE } - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) Index: src/huffman_tree.h ================================================================== --- src/huffman_tree.h +++ src/huffman_tree.h @@ -20,12 +20,10 @@ #import "macros.h" OF_ASSUME_NONNULL_BEGIN -@class OFStream; - struct of_huffman_tree { struct of_huffman_tree *_Nullable leaves[2]; uint16_t value; }; @@ -34,14 +32,14 @@ #endif extern struct of_huffman_tree *_Nonnull of_huffman_tree_construct( uint8_t lengths[_Nonnull], uint16_t count); extern struct of_huffman_tree *_Nonnull of_huffman_tree_construct_single( uint16_t value); -extern bool of_huffman_tree_walk(OFStream *_Nullable stream, - bool (*bitReader)(OFStream *_Nullable, uint16_t *_Nonnull, uint8_t), +extern bool of_huffman_tree_walk(id _Nullable stream, + bool (*bitReader)(id _Nullable, uint16_t *_Nonnull, uint8_t), struct of_huffman_tree *_Nonnull *_Nonnull tree, uint16_t *_Nonnull value); extern void of_huffman_tree_release(struct of_huffman_tree *_Nonnull tree); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/huffman_tree.m ================================================================== --- src/huffman_tree.m +++ src/huffman_tree.m @@ -109,12 +109,11 @@ return tree; } bool -of_huffman_tree_walk(OFStream *stream, - bool (*bitReader)(OFStream *, uint16_t *, uint8_t), +of_huffman_tree_walk(id stream, bool (*bitReader)(id, uint16_t *, uint8_t), struct of_huffman_tree **tree, uint16_t *value) { struct of_huffman_tree *iter = *tree; uint16_t bits;