ObjFW  Diff

Differences From Artifact [896b2f634c]:

To Artifact [e1df224af8]:


38
39
40
41
42
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57
58
38
39
40
41
42
43
44





45


46
47
48
49
50
51
52







-
-
-
-
-
+
-
-







	OFString *ret;

	string = self.UTF8String;
	length = self.UTF8StringLength;

	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
	retCString = of_malloc(retLength, 1);
		@throw [OFOutOfMemoryException
		    exceptionWithRequestedSize: 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
72
73
74
75
76
77
78




79
80
81
82
83

84


85

86
87
88
89
90
91
92







-
-
-
-
+
+
+
+

-
+
-
-

-







			break;
		default:
			append = NULL;
			appendLen = 0;
		}

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

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {
			@try {
				retCString = of_realloc(retCString, 1,
				    retLength + appendLen);
			} @catch (id e) {
				free(retCString);
				@throw [OFOutOfMemoryException
				@throw e;
				     exceptionWithRequestedSize: retLength +
								 appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

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