Differences From Artifact [95db2a693c]:
- File
src/OFDeflateStream.m
— part of check-in
[6b77a5dd8b]
at
2017-05-21 21:28:57
on branch trunk
— Prefix private methods with of_ instead of OF_
This matches Apple's style. (user: js, size: 20161) [annotate] [blame] [check-ins using]
To Artifact [f38e0e21e0]:
- File
src/OFDeflateStream.m
— part of check-in
[f9cd4f9cab]
at
2017-06-05 15:51:48
on branch trunk
— OFStream: Don't throw when at end of stream
Instead, let reads return 0 and let writes append after the end. (user: js, size: 20257) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
29 30 31 32 33 34 35 36 | # import "OFDeflate64Stream.h" # define OFDeflateStream OFDeflate64Stream #endif #import "OFDataArray.h" #import "OFInitializationFailedException.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" | > < | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # import "OFDeflate64Stream.h" # define OFDeflateStream OFDeflate64Stream #endif #import "OFDataArray.h" #import "OFInitializationFailedException.h" #import "OFInvalidFormatException.h" #import "OFNotOpenException.h" #import "OFOutOfMemoryException.h" #define BUFFER_SIZE OF_INFLATE_STREAM_BUFFER_SIZE #define MAX_BITS 15 enum state { BLOCK_HEADER, |
︙ | ︙ | |||
302 303 304 305 306 307 308 | _stream = [stream retain]; return self; } - (void)dealloc { | | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | _stream = [stream retain]; return self; } - (void)dealloc { [self close]; if (_decompression != NULL && _decompression->state == HUFFMAN_TREE) if (_decompression->context.huffmanTree.codeLenTree != NULL) releaseTree( _decompression->context.huffmanTree.codeLenTree); if (_decompression != NULL && (_decompression->state == HUFFMAN_TREE || |
︙ | ︙ | |||
347 348 349 350 351 352 353 354 355 356 357 358 359 | uint8_t *buffer = buffer_; uint16_t bits, tmp; uint16_t value; size_t bytesWritten = 0; uint8_t *slidingWindow; uint16_t slidingWindowIndex; if (ivars == NULL) { [self of_initDecompression]; ivars = _decompression; } if (ivars->atEndOfStream) | > > > < | | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | uint8_t *buffer = buffer_; uint16_t bits, tmp; uint16_t value; size_t bytesWritten = 0; uint8_t *slidingWindow; uint16_t slidingWindowIndex; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (ivars == NULL) { [self of_initDecompression]; ivars = _decompression; } if (ivars->atEndOfStream) return 0; start: switch ((enum state)ivars->state) { case BLOCK_HEADER: if OF_UNLIKELY (ivars->inLastBlock) { [_stream unreadFromBuffer: ivars->buffer + ivars->bufferIndex |
︙ | ︙ | |||
819 820 821 822 823 824 825 | OF_UNREACHABLE } #ifndef DEFLATE64 - (bool)lowlevelIsAtEndOfStream { | | | > > > > > > > > | 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 | OF_UNREACHABLE } #ifndef DEFLATE64 - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; return _decompression->atEndOfStream; } - (int)fileDescriptorForReading { return [_stream fileDescriptorForReading]; } - (bool)hasDataInReadBuffer { return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer]); } #endif - (void)close { [_stream release]; _stream = nil; [super close]; } @end |