ObjFW  Diff

Differences From Artifact [896b2f634c]:

To Artifact [5d08b70ba3]:


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: retLength];

	for (size_t i = 0; i < length; i++) {
		switch (string[i]) {
		case '<':
			append = "&lt;";
			appendLen = 4;
			break;







|
<
<







42
43
44
45
46
47
48
49


50
51
52
53
54
55
56

	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	retCString = of_malloc(1, retLength);



	for (size_t i = 0; i < length; i++) {
		switch (string[i]) {
		case '<':
			append = "&lt;";
			appendLen = 4;
			break;
78
79
80
81
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
			break;
		default:
			append = NULL;
			appendLen = 0;
		}

		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {

				free(retCString);
				@throw [OFOutOfMemoryException
				     exceptionWithRequestedSize: retLength +
								 appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else
			retCString[j++] = string[i];
	}
	assert(j == retLength);

	objc_autoreleasePoolPop(pool);

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: retLength];
	} @finally {
		free(retCString);
	}
	return ret;
}
@end







<
|
|
|
>
|
|
<
<

<















|




76
77
78
79
80
81
82

83
84
85
86
87
88


89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
			break;
		default:
			append = NULL;
			appendLen = 0;
		}

		if (append != NULL) {

			@try {
				retCString = of_realloc(retCString, 1,
				    retLength + appendLen);
			} @catch (id e) {
				of_free(retCString);
				@throw e;


			}

			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else
			retCString[j++] = string[i];
	}
	assert(j == retLength);

	objc_autoreleasePoolPop(pool);

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: retLength];
	} @finally {
		of_free(retCString);
	}
	return ret;
}
@end