102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
stream->_savedBits = ret;
stream->_savedBitsLength = i;
return false;
}
stream->_byte = stream->_buffer[0];
stream->_bufferIndex = 1;
stream->_bufferLength = length;
}
stream->_bitIndex = 0;
}
ret |= ((stream->_byte >> stream->_bitIndex++) & 1) << i;
}
|
|
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
stream->_savedBits = ret;
stream->_savedBitsLength = i;
return false;
}
stream->_byte = stream->_buffer[0];
stream->_bufferIndex = 1;
stream->_bufferLength = (uint_fast16_t)length;
}
stream->_bitIndex = 0;
}
ret |= ((stream->_byte >> stream->_bitIndex++) & 1) << i;
}
|
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
[super dealloc];
}
- (size_t)lowlevelReadIntoBuffer: (void*)buffer_
length: (size_t)length
{
uint8_t *buffer = buffer_;
uint_fast16_t bits;
uint16_t value;
size_t i, tmp, bytesWritten = 0;
uint8_t *slidingWindow;
uint_fast16_t slidingWindowIndex;
if (_atEndOfStream)
@throw [OFReadFailedException exceptionWithStream: self
requestedLength: length];
|
|
|
|
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
[super dealloc];
}
- (size_t)lowlevelReadIntoBuffer: (void*)buffer_
length: (size_t)length
{
uint8_t *buffer = buffer_;
uint_fast16_t bits, i, tmp;
uint16_t value;
size_t bytesWritten = 0;
uint8_t *slidingWindow;
uint_fast16_t slidingWindowIndex;
if (_atEndOfStream)
@throw [OFReadFailedException exceptionWithStream: self
requestedLength: length];
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
#undef CTX
case UNCOMPRESSED_BLOCK:
#define CTX _context.uncompressed
if OF_UNLIKELY (length == 0)
return bytesWritten;
tmp = (length < CTX.length - CTX.position
? length : CTX.length - CTX.position);
tmp = [_stream readIntoBuffer: buffer + bytesWritten
length: tmp];
if OF_UNLIKELY (_slidingWindow == NULL) {
_slidingWindow =
[self allocMemoryWithSize: _slidingWindowMask + 1];
/* Avoid leaking data */
memset(_slidingWindow, 0, _slidingWindowMask + 1);
}
|
|
>
|
|
|
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
#undef CTX
case UNCOMPRESSED_BLOCK:
#define CTX _context.uncompressed
if OF_UNLIKELY (length == 0)
return bytesWritten;
tmp = (length < CTX.length - CTX.position
? (uint_fast16_t)length : CTX.length - CTX.position);
tmp = (uint_fast16_t)[_stream
readIntoBuffer: buffer + bytesWritten
length: tmp];
if OF_UNLIKELY (_slidingWindow == NULL) {
_slidingWindow =
[self allocMemoryWithSize: _slidingWindowMask + 1];
/* Avoid leaking data */
memset(_slidingWindow, 0, _slidingWindowMask + 1);
}
|