ObjFW  Diff

Differences From Artifact [9a6d67963b]:

To Artifact [8447dff468]:


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
	free(class);
	objc_registerClassPair((Class)&_OFConstantStringClassReference);
#endif
}

- (void)finishInitialization
{

	struct of_string_utf8_ivars *ivars;




	if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithClass: [self class]
			 requestedSize: sizeof(*ivars)];

	ivars->cString = _cString;
	ivars->cStringLength = _cStringLength;

	switch (of_string_utf8_check(ivars->cString, ivars->cStringLength,

	    &ivars->length)) {
	case 1:
		ivars->isUTF8 = true;
		break;
	case -1:
		free(ivars);
		@throw [OFInvalidEncodingException
		    exceptionWithClass: [self class]];
	}

	_cString = (char*)ivars;
	object_setClass(self, [OFString_const class]);

}

+ alloc
{
	[self doesNotRecognizeSelector: _cmd];
	abort();
}







>
|

>
>
>
|
|
|
|

|
|

|
>
|
|
|
|
|
|
|
|
|

|
|
>







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
	free(class);
	objc_registerClassPair((Class)&_OFConstantStringClassReference);
#endif
}

- (void)finishInitialization
{
	@synchronized (self) {
		struct of_string_utf8_ivars *ivars;

		if (object_getClass(self) == [OFString_const class])
			return;

		if ((ivars = calloc(1, sizeof(*ivars))) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithClass: [self class]
				 requestedSize: sizeof(*ivars)];

		ivars->cString = _cString;
		ivars->cStringLength = _cStringLength;

		switch (of_string_utf8_check(ivars->cString,
		    ivars->cStringLength,
			&ivars->length)) {
			case 1:
				ivars->isUTF8 = true;
				break;
			case -1:
				free(ivars);
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
		}

		_cString = (char*)ivars;
		object_setClass(self, [OFString_const class]);
	}
}

+ alloc
{
	[self doesNotRecognizeSelector: _cmd];
	abort();
}