ObjFW  Diff

Differences From Artifact [2751804ef6]:

To Artifact [8e095b45a0]:


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116
117
118
119
85
86
87
88
89
90
91

92
93
94
95
96
97
98

99
100
101



102







103
104
105
106
107
108
109







-







-
+


-
-
-
+
-
-
-
-
-
-
-







		for (i = 0; i < hashtable->size; i++)
			data[i] = NULL;

		size = hashtable->size;
		count = hashtable->count;

		for (i = 0; i < size; i++) {
			id key;
			struct of_dictionary_hashtable_bucket *bucket;

			if (hashtable->data[i] == NULL ||
			    hashtable->data[i] == DELETED)
				continue;

			bucket = [self allocMemoryWithSize: sizeof(*bucket)];
			key = (copyKeys
			bucket->key = (copyKeys
			    ? [hashtable->data[i]->key copy]
			    : [hashtable->data[i]->key retain]);

			@try {
				[hashtable->data[i]->object retain];
			bucket->object = [hashtable->data[i]->object retain];
			} @catch (id e) {
				[key release];
				@throw e;
			}

			bucket->key = key;
			bucket->object = hashtable->data[i]->object;
			bucket->hash = hashtable->data[i]->hash;

			data[i] = bucket;
		}
	} @catch (id e) {
		[self release];
		@throw e;
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192

193
194
195


196
197
198
199
200
201
202
167
168
169
170
171
172
173

174


175





176



177
178
179
180
181
182
183
184
185







-

-
-
+
-
-
-
-
-
+
-
-
-
+
+







			}

			if (data[i] != NULL)
				@throw [OFOutOfRangeException
				    newWithClass: isa];

			bucket = [self allocMemoryWithSize: sizeof(*bucket)];
			key = [key copy];

			@try {
				object = [dictionary objectForKey: key];
			object = [dictionary objectForKey: key];
				[object retain];
			} @catch (id e) {
				[key release];
				@throw e;
			}


			bucket->key = key;
			bucket->object = object;
			bucket->key = [key copy];
			bucket->object = [object retain];
			bucket->hash = hash;

			data[i] = bucket;
		}

		[pool release];
	} @catch (id e) {
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242



243
244
245
246
247
248
249
207
208
209
210
211
212
213


214









215
216
217
218
219
220
221
222
223
224







-
-

-
-
-
-
-
-
-
-
-
+
+
+







					 withSize: sizeof(*data)];

		size = 2;
		for (i = 0; i < size; i++)
			data[i] = NULL;

		i = [key hash] & 1;
		bucket = [self allocMemoryWithSize: sizeof(*bucket)];
		key = [key copy];

		@try {
			[object retain];
		} @catch (id e) {
			[key release];
			@throw e;
		}

		bucket->key = key;
		bucket->object = object;
		bucket = [self allocMemoryWithSize: sizeof(*bucket)];
		bucket->key = [key copy];
		bucket->object = [object retain];
		bucket->hash = [key hash];

		data[i] = bucket;
		count = 1;
	} @catch (id e) {
		[self release];
		@throw e;
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357

358
359
360
361
362
363
364
365
366
367
368
369
300
301
302
303
304
305
306







307

308
309
310
311
312
313
314
315
316
317
318
319
320
321
322



323





324
325
326
327
328
329
330







-
-
-
-
-
-
-

-
+














-
-
-
+
-
-
-
-
-







					@throw [OFOutOfRangeException
					    newWithClass: isa];

				bucket =
				    [self allocMemoryWithSize: sizeof(*bucket)];
				key = [keysCArray[i] copy];

				@try {
					[objectsCArray[i] retain];
				} @catch (id e) {
					[key release];
					@throw e;
				}

				bucket->key = key;
				bucket->object = objectsCArray[i];
				bucket->object = [objectsCArray[i] retain];
				bucket->hash = hash;

				data[j] = bucket;

				continue;
			}

			/*
			 * The key is already in the dictionary. However, we
			 * just replace it so that the programmer gets the same
			 * behavior as if he'd call setObject:forKey: for each
			 * key/object pair.
			 */
			[objectsCArray[i] retain];

			@try {
				[data[j]->object release];
			[data[j]->object release];
			} @catch (id e) {
				[objectsCArray[i] release];
				@throw e;
			}

			data[j]->object = objectsCArray[i];
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}

414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431


432
433
434
435
436
437
438
375
376
377
378
379
380
381











382
383
384
385
386
387
388
389
390







-
-
-
-
-
-
-
-
-
-
-
+
+







		size = newSize;

		/* Add first key / object pair */
		hash = [key hash];
		j = hash & (size - 1);

		bucket = [self allocMemoryWithSize: sizeof(*bucket)];
		key = [key copy];

		@try {
			[object retain];
		} @catch (id e) {
			[key release];
			@throw e;
		}

		bucket->key = key;
		bucket->object = object;
		bucket->key = [key copy];
		bucket->object = [object retain];
		bucket->hash = hash;

		data[j] = bucket;

		for (i = 1; i < count; i++) {
			uint32_t last;

479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496


497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513

514
515
516
517
518
519
520
521
522
523
524
525
431
432
433
434
435
436
437











438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453



454





455
456
457
458
459
460
461







-
-
-
-
-
-
-
-
-
-
-
+
+














-
-
-
+
-
-
-
-
-








				if (j >= last)
					@throw [OFOutOfRangeException
					    newWithClass: isa];

				bucket =
				    [self allocMemoryWithSize: sizeof(*bucket)];
				key = [key copy];

				@try {
					[object retain];
				} @catch (id e) {
					[key release];
					@throw e;
				}

				bucket->key = key;
				bucket->object = object;
				bucket->key = [key copy];
				bucket->object = [object retain];
				bucket->hash = hash;

				data[j] = bucket;

				continue;
			}

			/*
			 * The key is already in the dictionary. However, we
			 * just replace it so that the programmer gets the same
			 * behavior as if he'd call setObject:forKey: for each
			 * key/object pair.
			 */
			[object retain];

			@try {
				[data[j]->object release];
			[data[j]->object release];
			} @catch (id e) {
				[object release];
				@throw e;
			}

			data[j]->object = object;
			count--;
		}
	} @catch (id e) {
		[self release];
		@throw e;
	}