ObjFW  Check-in [f5c4220251]

Overview
Comment:Check more arguments for nil.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f5c422025133239f6895ab11107c9505c0599ca82d80f90f7114e11c6d3dfbe9
User & Date: js on 2012-11-12 11:24:46
Other Links: manifest | tags
Context
2012-11-12
11:30
Update ChangeLog for 0.7.1. check-in: f2e5c1b668 user: js tags: trunk
11:24
Check more arguments for nil. check-in: f5c4220251 user: js tags: trunk
2012-11-11
12:12
Add -[OFString stringByAppendingFormat:]. check-in: da23dca008 user: js tags: trunk
Changes

Modified src/OFArray.m from [626ce7ee3d] to [4f7e60625c].

169
170
171
172
173
174
175






176
177
178
179
180
181
182
	}

	return [super init];
}

- initWithObject: (id)object
{






	return [self initWithObjects: object, nil];
}

- initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;







>
>
>
>
>
>







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
	}

	return [super init];
}

- initWithObject: (id)object
{
	if (object == nil) {
		Class c = [self class];
		[self release];
		@throw [OFInvalidArgumentException exceptionWithClass: c];
	}

	return [self initWithObjects: object, nil];
}

- initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;
274
275
276
277
278
279
280
281





282
283
284
285
286
287
288
289
290
291
292





293
294
295
296
297
298
299
- (id)objectAtIndexedSubscript: (size_t)index
{
	return [self objectAtIndex: index];
}

- (size_t)indexOfObject: (id)object
{
	size_t i, count = [self count];






	for (i = 0; i < count; i++)
		if ([[self objectAtIndex: i] isEqual: object])
			return i;

	return OF_NOT_FOUND;
}

- (size_t)indexOfObjectIdenticalTo: (id)object
{
	size_t i, count = [self count];






	for (i = 0; i < count; i++)
		if ([self objectAtIndex: i] == object)
			return i;

	return OF_NOT_FOUND;
}







|
>
>
>
>
>










|
>
>
>
>
>







280
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
306
307
308
309
310
311
312
313
314
315
- (id)objectAtIndexedSubscript: (size_t)index
{
	return [self objectAtIndex: index];
}

- (size_t)indexOfObject: (id)object
{
	size_t i, count;

	if (object == nil)
		return OF_NOT_FOUND;

	count = [self count];

	for (i = 0; i < count; i++)
		if ([[self objectAtIndex: i] isEqual: object])
			return i;

	return OF_NOT_FOUND;
}

- (size_t)indexOfObjectIdenticalTo: (id)object
{
	size_t i, count;

	if (object == nil)
		return OF_NOT_FOUND;

	count = [self count];

	for (i = 0; i < count; i++)
		if ([self objectAtIndex: i] == object)
			return i;

	return OF_NOT_FOUND;
}
363
364
365
366
367
368
369
370
371






372
373
374
375
376
377
378

- (OFString*)componentsJoinedByString: (OFString*)separator
			usingSelector: (SEL)selector
{
	void *pool;
	OFMutableString *ret;
	id *objects;
	size_t i, count = [self count];
	IMP append;







	if (count == 0)
		return @"";
	if (count == 1)
		return [[self firstObject] performSelector: selector];

	ret = [OFMutableString string];







|

>
>
>
>
>
>







379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400

- (OFString*)componentsJoinedByString: (OFString*)separator
			usingSelector: (SEL)selector
{
	void *pool;
	OFMutableString *ret;
	id *objects;
	size_t i, count;
	IMP append;

	if (separator == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	if (count == 0)
		return @"";
	if (count == 1)
		return [[self firstObject] performSelector: selector];

	ret = [OFMutableString string];
606
607
608
609
610
611
612






613
614
615
616
617
618
619
620
			break;
	}
}
#endif

- (OFArray*)arrayByAddingObject: (id)object
{






	OFMutableArray *ret = [[self mutableCopy] autorelease];

	[ret addObject: object];
	[ret makeImmutable];

	return ret;
}








>
>
>
>
>
>
|







628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
			break;
	}
}
#endif

- (OFArray*)arrayByAddingObject: (id)object
{
	OFMutableArray *ret;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	ret = [[self mutableCopy] autorelease];

	[ret addObject: object];
	[ret makeImmutable];

	return ret;
}

Modified src/OFArray_adjacent.m from [cdb0c9cc7a] to [7116965323].

48
49
50
51
52
53
54




55
56
57
58
59
60
61
}

- initWithObject: (id)object
{
	self = [self init];

	@try {




		[array addItem: &object];
		[object retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}








>
>
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
}

- initWithObject: (id)object
{
	self = [self init];

	@try {
		if (object == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		[array addItem: &object];
		[object retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

88
89
90
91
92
93
94



95
96
97
98
99
100
101
- initWithArray: (OFArray*)array_
{
	id *objects;
	size_t i, count;

	self = [self init];




	@try {
		objects = [array_ objects];
		count = [array_ count];
	} @catch (id e) {
		[self release];
		@throw e;
	}







>
>
>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
- initWithArray: (OFArray*)array_
{
	id *objects;
	size_t i, count;

	self = [self init];

	if (array_ == nil)
		return self;

	@try {
		objects = [array_ objects];
		count = [array_ count];
	} @catch (id e) {
		[self release];
		@throw e;
	}
124
125
126
127
128
129
130

131
132



133





134
135
136
137
138
139
140
- initWithObjects: (id const*)objects
	    count: (size_t)count
{
	self = [self init];

	@try {
		size_t i;


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



			[objects[i] retain];






		[array addItemsFromCArray: objects
				    count: count];
	} @catch (id e) {
		size_t i;

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







>

|
>
>
>

>
>
>
>
>







131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
- initWithObjects: (id const*)objects
	    count: (size_t)count
{
	self = [self init];

	@try {
		size_t i;
		BOOL ok = YES;

		for (i = 0; i < count; i++) {
			if (objects[i] == nil)
				ok = NO;

			[objects[i] retain];
		}

		if (!ok)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		[array addItemsFromCArray: objects
				    count: count];
	} @catch (id e) {
		size_t i;

		for (i = 0; i < count; i++)
218
219
220
221
222
223
224






225
226
227
228
229
230
231
232
233
234
235
236






237
238
239
240
241
242
243
244
245

	for (i = 0; i < range.length; i++)
		buffer[i] = objects[range.location + i];
}

- (size_t)indexOfObject: (id)object
{






	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		if ([objects[i] isEqual: object])
			return i;

	return OF_NOT_FOUND;
}

- (size_t)indexOfObjectIdenticalTo: (id)object
{






	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		if (objects[i] == object)
			return i;

	return OF_NOT_FOUND;
}







>
>
>
>
>
>
|
|










>
>
>
>
>
>
|
|







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273

	for (i = 0; i < range.length; i++)
		buffer[i] = objects[range.location + i];
}

- (size_t)indexOfObject: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		return OF_NOT_FOUND;

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++)
		if ([objects[i] isEqual: object])
			return i;

	return OF_NOT_FOUND;
}

- (size_t)indexOfObjectIdenticalTo: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		return OF_NOT_FOUND;

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++)
		if (objects[i] == object)
			return i;

	return OF_NOT_FOUND;
}

Modified src/OFDictionary.m from [9c777b7efa] to [a3f4a24963].

20
21
22
23
24
25
26

27
28
29
30
31
32
33

#import "OFDictionary.h"
#import "OFDictionary_hashtable.h"
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"


#import "OFNotImplementedException.h"

#import "autorelease.h"

static struct {
	Class isa;
} placeholder;







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#import "OFDictionary.h"
#import "OFDictionary_hashtable.h"
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"

#import "OFInvalidArgumentException.h"
#import "OFNotImplementedException.h"

#import "autorelease.h"

static struct {
	Class isa;
} placeholder;
198
199
200
201
202
203
204




205
206
207
208
209
210
211
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithObject: (id)object
	  forKey: (id)key
{




	return [self initWithKeysAndObjects: key, object, nil];
}

- initWithObjects: (OFArray*)objects
	  forKeys: (OFArray*)keys
{
	Class c = [self class];







>
>
>
>







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithObject: (id)object
	  forKey: (id)key
{
	if (key == nil || object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	return [self initWithKeysAndObjects: key, object, nil];
}

- initWithObjects: (OFArray*)objects
	  forKeys: (OFArray*)keys
{
	Class c = [self class];
312
313
314
315
316
317
318
319
320
321
322






323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340






341
342
343
344
345
346
347
	objc_autoreleasePoolPop(pool);

	return YES;
}

- (BOOL)containsObject: (id)object
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id currentObject;







	while ((currentObject = [enumerator nextObject]) != nil) {
		if ([currentObject isEqual: object]) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}

	objc_autoreleasePoolPop(pool);

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id currentObject;







	while ((currentObject = [enumerator nextObject]) != nil) {
		if (currentObject == object) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}








|
|


>
>
>
>
>
>














|
|


>
>
>
>
>
>







317
318
319
320
321
322
323
324
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
	objc_autoreleasePoolPop(pool);

	return YES;
}

- (BOOL)containsObject: (id)object
{
	void *pool;
	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return NO;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	while ((currentObject = [enumerator nextObject]) != nil) {
		if ([currentObject isEqual: object]) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}

	objc_autoreleasePoolPop(pool);

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	void *pool;
	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return NO;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	while ((currentObject = [enumerator nextObject]) != nil) {
		if (currentObject == object) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}

Modified src/OFDictionary_hashtable.m from [f94483610d] to [a181bd3b11].

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
	self = [super init];

	@try {
		uint32_t i;
		OFDictionary_hashtable *hashtable;

		if (dictionary == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		if (![dictionary isKindOfClass:
		    [OFDictionary_hashtable class]] &&
		    ![dictionary isKindOfClass:
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];







<
<
<
<
<







62
63
64
65
66
67
68





69
70
71
72
73
74
75
{
	self = [super init];

	@try {
		uint32_t i;
		OFDictionary_hashtable *hashtable;






		if (![dictionary isKindOfClass:
		    [OFDictionary_hashtable class]] &&
		    ![dictionary isKindOfClass:
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];
112
113
114
115
116
117
118



119
120
121
122
123
124
125
126
127
128
129
130
131




132
133
134
135
136
137
138
	}

	return self;
}

- initWithDictionary: (OFDictionary*)dictionary
{



	if ([dictionary class] == [OFDictionary_hashtable class] ||
	    [dictionary class] == [OFMutableDictionary_hashtable class])
		return [self OF_initWithDictionary: dictionary
					  copyKeys: YES];

	self = [super init];

	@try {
		void *pool;
		OFEnumerator *enumerator;
		id key;
		uint32_t i, newSize;





		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (newSize = 1; newSize < count; newSize <<= 1);







>
>
>













>
>
>
>







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	}

	return self;
}

- initWithDictionary: (OFDictionary*)dictionary
{
	if (dictionary == nil)
		return [self init];

	if ([dictionary class] == [OFDictionary_hashtable class] ||
	    [dictionary class] == [OFMutableDictionary_hashtable class])
		return [self OF_initWithDictionary: dictionary
					  copyKeys: YES];

	self = [super init];

	@try {
		void *pool;
		OFEnumerator *enumerator;
		id key;
		uint32_t i, newSize;

		if (dictionary == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (newSize = 1; newSize < count; newSize <<= 1);
284
285
286
287
288
289
290




291
292
293
294
295
296
297
		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {
			uint32_t hash, last;





			hash = [keys[i] hash];
			last = size;

			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([data[j]->key isEqual: keys[i]])







>
>
>
>







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {
			uint32_t hash, last;

			if (keys[i] == nil || objects[i] == nil)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]];

			hash = [keys[i] hash];
			last = size;

			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([data[j]->key isEqual: keys[i]])
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
	return YES;
}

- (BOOL)containsObject: (id)object
{
	uint32_t i;

	if (count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    [data[i]->object isEqual: object])
			return YES;

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	uint32_t i;

	if (count == 0)
		return NO;

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








|














|







626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
	return YES;
}

- (BOOL)containsObject: (id)object
{
	uint32_t i;

	if (object == nil || count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    [data[i]->object isEqual: object])
			return YES;

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	uint32_t i;

	if (object == nil || count == 0)
		return NO;

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

Modified src/OFMutableArray.m from [880c8c3997] to [ef9ecd25ad].

228
229
230
231
232
233
234
235






236
237
238
239
240
241
242
243
244
245
246
247
248
249






250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269






270
271
272
273
274
275
276
277
278
279
280
281
282






283
284
285
286
287
288
289
	[self replaceObjectAtIndex: index
			withObject: object];
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t i, count = [self count];







	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: oldObject]) {
			[self replaceObjectAtIndex: i
					withObject: newObject];
			return;
		}
	}
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	size_t i, count = [self count];







	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == oldObject) {
			[self replaceObjectAtIndex: i
					withObject: newObject];

			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
{
	@throw [OFNotImplementedException exceptionWithClass: [self class]
						    selector: _cmd];
}

- (void)removeObject: (id)object
{
	size_t i, count = [self count];







	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: object]) {
			[self removeObjectAtIndex: i];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{
	size_t i, count = [self count];







	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == object) {
			[self removeObjectAtIndex: i];

			return;
		}







|
>
>
>
>
>
>













|
>
>
>
>
>
>



















|
>
>
>
>
>
>












|
>
>
>
>
>
>







228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
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
306
307
308
309
310
311
312
313
	[self replaceObjectAtIndex: index
			withObject: object];
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: oldObject]) {
			[self replaceObjectAtIndex: i
					withObject: newObject];
			return;
		}
	}
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == oldObject) {
			[self replaceObjectAtIndex: i
					withObject: newObject];

			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
{
	@throw [OFNotImplementedException exceptionWithClass: [self class]
						    selector: _cmd];
}

- (void)removeObject: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([[self objectAtIndex: i] isEqual: object]) {
			[self removeObjectAtIndex: i];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	count = [self count];

	for (i = 0; i < count; i++) {
		if ([self objectAtIndex: i] == object) {
			[self removeObjectAtIndex: i];

			return;
		}

Modified src/OFMutableArray_adjacent.m from [d741de4264] to [6fbb272bbe].

31
32
33
34
35
36
37




38
39
40
41
42
43
44
45
46




47
48
49
50
51
52
53
{
	if (self == [OFMutableArray_adjacent class])
		[self inheritMethodsFromClass: [OFArray_adjacent class]];
}

- (void)addObject: (id)object
{




	[array addItem: &object];
	[object retain];

	mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{




	[array insertItem: &object
		  atIndex: index];
	[object retain];

	mutations++;
}








>
>
>
>









>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
	if (self == [OFMutableArray_adjacent class])
		[self inheritMethodsFromClass: [OFArray_adjacent class]];
}

- (void)addObject: (id)object
{
	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	[array addItem: &object];
	[object retain];

	mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
{
	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	[array insertItem: &object
		  atIndex: index];
	[object retain];

	mutations++;
}

66
67
68
69
70
71
72







73
74
75
76
77
78
79
80
81
82
83
84
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







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138







139
140
141
142
143
144
145
146
147

	mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{







	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;

			return;
		}
	}
}

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	id *objects = [array cArray];
	id oldObject;







	if (index >= [array count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	oldObject = objects[index];
	objects[index] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{







	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;

			return;
		}
	}
}

- (void)removeObject: (id)object
{







	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];

			[array removeItemAtIndex: i];
			mutations++;

			[object release];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{







	id *objects = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[array removeItemAtIndex: i];
			mutations++;

			[object release];







>
>
>
>
>
>
>
|
|















|


>
>
>
>
>
>











>
>
>
>
>
>
>
|
|














>
>
>
>
>
>
>
|
|

















>
>
>
>
>
>
>
|
|







74
75
76
77
78
79
80
81
82
83
84
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

	mutations++;
}

- (void)replaceObject: (id)oldObject
	   withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: oldObject]) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;

			return;
		}
	}
}

- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)object
{
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];

	if (index >= [array count])
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	oldObject = objects[index];
	objects[index] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	id *objects;
	size_t i, count;

	if (oldObject == nil || newObject == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == oldObject) {
			[newObject retain];
			[objects[i] release];
			objects[i] = newObject;

			return;
		}
	}
}

- (void)removeObject: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if ([objects[i] isEqual: object]) {
			object = objects[i];

			[array removeItemAtIndex: i];
			mutations++;

			[object release];

			return;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)object
{
	id *objects;
	size_t i, count;

	if (object == nil)
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]];

	objects = [array cArray];
	count = [array count];

	for (i = 0; i < count; i++) {
		if (objects[i] == object) {
			[array removeItemAtIndex: i];
			mutations++;

			[object release];

Modified src/OFMutableSet.m from [e5b23d482d] to [0f6765c635].

160
161
162
163
164
165
166
167
168
169
170


171
172
173
174
175
176
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
	size_t count = [self count];
	id *cArray;

	cArray = [self allocMemoryWithSize: sizeof(id)
				     count: count];

	@try {
		OFEnumerator *enumerator = [self objectEnumerator];
		id object;
		size_t i = 0;



		while ((object = [enumerator nextObject]) != nil) {
			assert(i < count);
			cArray[i++] = object;
		}

		for (i = 0; i < count; i++)
			if (![set containsObject: cArray[i]])
			      [self removeObject: cArray[i]];
	} @finally {
		[self freeMemory: cArray];
	}

	objc_autoreleasePoolPop(pool);
}

- (void)unionSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [set objectEnumerator];
	id object;


	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	objc_autoreleasePoolPop(pool);
}

- (void)makeImmutable
{
}
@end







|

|

>
>


















|


>










160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
203
204
	size_t count = [self count];
	id *cArray;

	cArray = [self allocMemoryWithSize: sizeof(id)
				     count: count];

	@try {
		OFEnumerator *enumerator;
		id object;
		size_t i;

		i = 0;
		enumerator = [self objectEnumerator];
		while ((object = [enumerator nextObject]) != nil) {
			assert(i < count);
			cArray[i++] = object;
		}

		for (i = 0; i < count; i++)
			if (![set containsObject: cArray[i]])
			      [self removeObject: cArray[i]];
	} @finally {
		[self freeMemory: cArray];
	}

	objc_autoreleasePoolPop(pool);
}

- (void)unionSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;

	enumerator = [set objectEnumerator];
	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	objc_autoreleasePoolPop(pool);
}

- (void)makeImmutable
{
}
@end

Modified src/OFSet.m from [64a43ff987] to [da395819f0].

322
323
324
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
{
	return [[OFMutableSet alloc] initWithSet: self];
}

- (BOOL)isSubsetOfSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;


	while ((object = [enumerator nextObject]) != nil) {
		if (![set containsObject: object]) {
			objc_autoreleasePoolPop(pool);
			return NO;
		}
	}

	objc_autoreleasePoolPop(pool);

	return YES;
}

- (BOOL)intersectsSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator = [self objectEnumerator];
	id object;


	while ((object = [enumerator nextObject]) != nil) {
		if ([set containsObject: object]) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}








|


>















|


>







322
323
324
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
{
	return [[OFMutableSet alloc] initWithSet: self];
}

- (BOOL)isSubsetOfSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;

	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		if (![set containsObject: object]) {
			objc_autoreleasePoolPop(pool);
			return NO;
		}
	}

	objc_autoreleasePoolPop(pool);

	return YES;
}

- (BOOL)intersectsSet: (OFSet*)set
{
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *enumerator;
	id object;

	enumerator = [self objectEnumerator];
	while ((object = [enumerator nextObject]) != nil) {
		if ([set containsObject: object]) {
			objc_autoreleasePoolPop(pool);
			return YES;
		}
	}

Modified src/OFSet_hashtable.m from [246ec8ee26] to [b5f65d1f93].

46
47
48
49
50
51
52



53
54
55
56
57


58
59
60
61
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80



81
82
83

84
85
86
87

88
89
90
91
92
93
94
95
96
	return self;
}

- initWithSet: (OFSet*)set
{
	self = [self init];




	@try {
		void *pool = objc_autoreleasePoolPush();
		OFNumber *one = [OFNumber numberWithSize: 1];
		OFEnumerator *enumerator = [set objectEnumerator];
		id object;



		/*
		 * We can't just copy the dictionary as the specified set might
		 * be a counted set, but we're just a normal set.
		 */

		while ((object = [enumerator nextObject]) != nil)
			[dictionary OF_setObject: one
					  forKey: object
					 copyKey: NO];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithArray: (OFArray*)array
{
	self = [self init];




	@try {
		void *pool = objc_autoreleasePoolPush();
		OFNumber *one = [OFNumber numberWithSize: 1];

		id *objects = [array objects];
		size_t i, count = [array count];

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

			[dictionary OF_setObject: one
					  forKey: objects[i]
					 copyKey: NO];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}







>
>
>


|
|

>
>





>


















>
>
>



>
|
<

|
>

|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102
103
104
105
106
	return self;
}

- initWithSet: (OFSet*)set
{
	self = [self init];

	if (set == nil)
		return self;

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFNumber *one;
		OFEnumerator *enumerator;
		id object;

		one = [OFNumber numberWithSize: 1];

		/*
		 * We can't just copy the dictionary as the specified set might
		 * be a counted set, but we're just a normal set.
		 */
		enumerator = [set objectEnumerator];
		while ((object = [enumerator nextObject]) != nil)
			[dictionary OF_setObject: one
					  forKey: object
					 copyKey: NO];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithArray: (OFArray*)array
{
	self = [self init];

	if (array == nil)
		return self;

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFNumber *one = [OFNumber numberWithSize: 1];
		OFEnumerator *enumerator;
		id object;


		enumerator = [array objectEnumerator];
		while ((object = [enumerator nextObject]) != nil)
			[dictionary OF_setObject: one
					  forKey: object
					 copyKey: NO];

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}
200
201
202
203
204
205
206



207
208
209
210
211
212
213
- (size_t)count
{
	return [dictionary count];
}

- (BOOL)containsObject: (id)object
{



	return ([dictionary objectForKey: object] != nil);
}

- (BOOL)isEqual: (id)object
{
	OFSet_hashtable *otherSet;








>
>
>







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
- (size_t)count
{
	return [dictionary count];
}

- (BOOL)containsObject: (id)object
{
	if (object == nil)
		return NO;

	return ([dictionary objectForKey: object] != nil);
}

- (BOOL)isEqual: (id)object
{
	OFSet_hashtable *otherSet;