ObjFW  Diff

Differences From Artifact [5f67a0c8ca]:

To Artifact [d918183a6a]:


122
123
124
125
126
127
128
129

130
131
132
133
134
135
136
122
123
124
125
126
127
128

129
130
131
132
133
134
135
136







-
+







{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	char *str_c;
	size_t len, i, j, attrs_count;
	OFXMLAttribute **attrs_carray;
	OFString *ret, *tmp;

	len = [name cStringLength] + 4;
	len = [name cStringLength] + 3;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	*str_c = '<';
	memcpy(str_c + 1, [name cString], [name cStringLength]);
	i = [name cStringLength] + 1;

200
201
202
203
204
205
206
207
208
209
210
211
212
213


214
215
216
217
218
219
220
221
222
223
224
200
201
202
203
204
205
206

207
208
209
210
211

212
213
214
215
216

217
218
219
220
221
222
223







-





-
+
+



-







		str_c[i++] = '/';
		memcpy(str_c + i, [name cString], [name cStringLength]);
		i += [name cStringLength];
	} else
		str_c[i++] = '/';

	str_c[i++] = '>';
	str_c[i++] = '\0';
	assert(i == len);

	[pool release];

	@try {
		ret = [OFString stringWithCString: str_c];
		ret = [OFString stringWithCString: str_c
					   length: len];
	} @finally {
		[self freeMemory: str_c];
	}

	return ret;
}

- addAttribute: (OFXMLAttribute*)attr
{
	if (attrs == nil)
		attrs = [[OFMutableArray alloc] init];
276
277
278
279
280
281
282
283

284
285
286
287
288

289
290
291
292
293
294
295
275
276
277
278
279
280
281

282
283
284
285
286

287
288
289
290
291
292
293
294







-
+




-
+







{
	char *str_c, *append, *tmp;
	size_t len, append_len;
	size_t i, j;
	OFString *ret;

	j = 0;
	len = length + 1;
	len = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((str_c = malloc(len + 1)) == NULL)
	if ((str_c = malloc(len)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
						       size: len];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
328
329
330
331
332
333
334
335
336
337
338
339


340
341
342
343
344
345
346
327
328
329
330
331
332
333

334
335
336

337
338
339
340
341

342
343
344







-



-
+
+



-




			memcpy(str_c + j, append, append_len);
			j += append_len;
		} else
			str_c[j++] = string[i];
	}

	str_c[j++] = '\0';
	assert(j == len);

	@try {
		ret = [OFString stringWithCString: str_c];
		ret = [OFString stringWithCString: str_c
					   length: len];
	} @finally {
		free(str_c);
	}

	return ret;
}
@end