ObjFW  Diff

Differences From Artifact [190d9e84e0]:

To Artifact [5a6af4a224]:

  • File src/OFXMLElement+Serialization.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: 1484) [annotate] [blame] [check-ins using]


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	Class class;
	id object;

	pool = [[OFAutoreleasePool alloc] init];

	if ((class = objc_lookUpClass([name cStringWithEncoding:
	    OF_STRING_ENCODING_ASCII])) == Nil)
		@throw [OFNotImplementedException newWithClass: Nil];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    newWithClass: class
			selector: @selector(initWithSerialization:)];

	object = [[class alloc] initWithSerialization: self];

	[pool release];

	return [object autorelease];
}
@end







|



|
|








36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	Class class;
	id object;

	pool = [[OFAutoreleasePool alloc] init];

	if ((class = objc_lookUpClass([name cStringWithEncoding:
	    OF_STRING_ENCODING_ASCII])) == Nil)
		@throw [OFNotImplementedException exceptionWithClass: Nil];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    exceptionWithClass: class
			      selector: @selector(initWithSerialization:)];

	object = [[class alloc] initWithSerialization: self];

	[pool release];

	return [object autorelease];
}
@end