ObjFW  Diff

Differences From Artifact [d47bbbd95a]:

To Artifact [f3d57089d4]:


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
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







-
+








-
-
+
+
+
-

-
+








		switch (check_utf8(str, length)) {
			case 1:
				is_utf8 = YES;
				break;
			case -1:
				c = isa;
				[super free];
				[super dealloc];
				@throw [OFInvalidEncodingException
					newWithClass: c];
		}

		@try {
			string = [self allocWithSize: length + 1];
		} @catch (OFException *e) {
			/*
			 * We can't use [super free] on OS X here. Compiler bug?
			 * [self free] will do here as we don't reimplement
			 * We can't use [super dealloc] on OS X here.
			 * Compiler bug? Anyway, [self dealloc] will do here as
			 * we don't reimplement dealloc.
			 * free.
			 */
			[self free];
			[self dealloc];
			@throw e;
		}
		memcpy(string, str, length + 1);
	}

	return self;
}
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
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







-
+





-
+











-
+







	int t;
	Class c;

	self = [super init];

	if (fmt == NULL) {
		c = isa;
		[super free];
		[super dealloc];
		@throw [OFInvalidFormatException newWithClass: c];
	}

	if ((t = vasprintf(&string, fmt, args)) == -1) {
		c = isa;
		[super free];
		[super dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
	}
	length = t;

	switch (check_utf8(string, length)) {
		case 1:
			is_utf8 = YES;
			break;
		case -1:
			free(string);
			c = isa;
			[super free];
			[super dealloc];
			@throw [OFInvalidEncodingException newWithClass: c];
	}

	@try {
		[self addToMemoryPool: string];
	} @catch (OFException *e) {
		free(string);