ObjFW  Diff

Differences From Artifact [c77b46c66d]:

To Artifact [81e5d7fd45]:


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		hashtable = (OFDictionary_hashtable*)dictionary;

		data = [self allocMemoryWithItemSize: sizeof(*data)
					       count: hashtable->size];

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

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








|
|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		hashtable = (OFDictionary_hashtable*)dictionary;

		data = [self allocMemoryWithSize: sizeof(*data)
					   count: hashtable->size];

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

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

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithItemSize: sizeof(*data)
					       count: newSize];

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

		size = newSize;

		pool = [[OFAutoreleasePool alloc] init];







|
|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithSize: sizeof(*data)
					   count: newSize];

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

		size = newSize;

		pool = [[OFAutoreleasePool alloc] init];
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
		struct of_dictionary_hashtable_bucket *bucket;

		if (key == nil || object == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		data = [self allocMemoryWithItemSize: sizeof(*data)
					       count: 2];

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

		i = [key hash] & 1;








|
|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
		struct of_dictionary_hashtable_bucket *bucket;

		if (key == nil || object == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		data = [self allocMemoryWithSize: sizeof(*data)
					   count: 2];

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

		i = [key hash] & 1;

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithItemSize: sizeof(*data)
					       count: newSize];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {







|
|







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithSize: sizeof(*data)
					   count: newSize];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithItemSize: sizeof(*data)
					       count: newSize];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		/* Add first key / object pair */







|
|







391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
		for (newSize = 1; newSize < count; newSize <<= 1);
		if (count * 4 / newSize >= 3)
			newSize <<= 1;

		if (newSize == 0)
			@throw [OFOutOfRangeException exceptionWithClass: isa];

		data = [self allocMemoryWithSize: sizeof(*data)
					   count: newSize];

		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		/* Add first key / object pair */
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659

	return NO;
}

- (OFArray*)allKeys
{
	OFArray *ret;
	id *keys = [self allocMemoryWithItemSize: sizeof(*keys)
					   count: count];
	size_t i, j;

	for (i = j = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			keys[j++] = data[i]->key;

	assert(j == count);







|
|







644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659

	return NO;
}

- (OFArray*)allKeys
{
	OFArray *ret;
	id *keys = [self allocMemoryWithSize: sizeof(*keys)
				       count: count];
	size_t i, j;

	for (i = j = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			keys[j++] = data[i]->key;

	assert(j == count);
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682

	return ret;
}

- (OFArray*)allObjects
{
	OFArray *ret;
	id *objects = [self allocMemoryWithItemSize: sizeof(*objects)
					      count: count];
	size_t i, j;

	for (i = j = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			objects[j++] = data[i]->object;

	assert(j == count);







|
|







667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682

	return ret;
}

- (OFArray*)allObjects
{
	OFArray *ret;
	id *objects = [self allocMemoryWithSize: sizeof(*objects)
					  count: count];
	size_t i, j;

	for (i = j = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			objects[j++] = data[i]->object;

	assert(j == count);