ObjFW  Diff

Differences From Artifact [831950ce9b]:

To Artifact [d472eede07]:

  • File src/OFArray_adjacent.m — part of check-in [e1e7ffa903] at 2011-09-22 23:25:42 on branch trunk — Exceptions are now autoreleased.

    This is safe as an "exception loop" can't happen, since if allocating
    an exception fails, it throws an OFAllocFailedException which is
    preallocated and can always be thrown.

    So, the worst case would be that an autorelease of an exception fails,
    triggering an OFOutOfMemoryException for which there is no memory,
    resulting in an OFAllocFailedException to be thrown. (user: js, size: 6562) [annotate] [blame] [check-ins using]


185
186
187
188
189
190
191
192
193



194
195
196
197
198
199
200
185
186
187
188
189
190
191


192
193
194
195
196
197
198
199
200
201







-
-
+
+
+







		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

		if ((![[element name] isEqual: @"OFArray"] &&
		    ![[element name] isEqual: @"OFMutableArray"]) ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		enumerator = [[element children] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			id object;

235
236
237
238
239
240
241
242

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

243
244
245
246
247
248
249
250







-
+







- (void)getObjects: (id*)buffer
	   inRange: (of_range_t)range
{
	id *cArray = [array cArray];
	size_t i, count = [array count];

	if (range.start + range.length > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

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

- (size_t)indexOfObject: (id)object
{
277
278
279
280
281
282
283
284

285
286
287
288
289
290
291
278
279
280
281
282
283
284

285
286
287
288
289
290
291
292







-
+







	if (![self isKindOfClass: [OFMutableArray class]])
		return [OFArray_adjacentSubarray arrayWithArray: self
							  range: range];

	count = [array count];

	if (range.start + range.length > count)
		@throw [OFOutOfRangeException newWithClass: isa];
		@throw [OFOutOfRangeException exceptionWithClass: isa];

	return [OFArray arrayWithCArray: (id*)[array cArray] + range.start
				 length: range.length];
}

- (BOOL)isEqual: (id)object
{