ObjFW  Diff

Differences From Artifact [459199aede]:

To Artifact [be9beadf26]:


150
151
152
153
154
155
156
157

158
159
160
161
162
163
164
150
151
152
153
154
155
156

157
158
159
160
161
162
163
164







-
+







	ivars->savedBits = 0;
	ivars->savedBitsLength = 0;
	*bits = ret;

	return true;
}

static struct huffman_tree*
static struct huffman_tree *
newTree(void)
{
	struct huffman_tree *tree;

	if ((tree = malloc(sizeof(*tree))) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: sizeof(*tree)];
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198







-
+








		tree = tree->leafs[bit];
	}

	tree->value = value;
}

static struct huffman_tree*
static struct huffman_tree *
constructTree(uint8_t lengths[], uint16_t count)
{
	struct huffman_tree *tree;
	uint16_t lengthCount[MAX_BITS + 1] = { 0 };
	uint16_t code, maxCode = 0, nextCode[MAX_BITS + 1];

	for (uint16_t i = 0; i < count; i++) {
281
282
283
284
285
286
287
288

289
290
291
292
293
294
295
296
297
298

299
300
301
302
303
304
305
281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
297

298
299
300
301
302
303
304
305







-
+









-
+







	for (uint16_t i = 0; i <= 31; i++)
		lengths[i] = 5;

	fixedDistTree = constructTree(lengths, 32);
}

#ifndef DEFLATE64
+ (instancetype)streamWithStream: (OFStream*)stream
+ (instancetype)streamWithStream: (OFStream *)stream
{
	return [[[self alloc] initWithStream: stream] autorelease];
}

- init
{
	OF_INVALID_INIT_METHOD
}

- initWithStream: (OFStream*)stream
- initWithStream: (OFStream *)stream
{
	self = [super init];

	_stream = [stream retain];

	return self;
}
336
337
338
339
340
341
342
343

344
345
346
347
348
349
350
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350







-
+







#ifdef DEFLATE64
	_decompression->slidingWindowMask = 0xFFFF;
#else
	_decompression->slidingWindowMask = 0x7FFF;
#endif
}

- (size_t)lowlevelReadIntoBuffer: (void*)buffer_
- (size_t)lowlevelReadIntoBuffer: (void *)buffer_
			  length: (size_t)length
{
	struct of_deflate_stream_decompression_ivars *ivars = _decompression;
	uint8_t *buffer = buffer_;
	uint16_t bits, tmp;
	uint16_t value;
	size_t bytesWritten = 0;