36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
OFString *ret;
string = self.UTF8String;
length = self.UTF8StringLength;
j = 0;
retLength = length;
retCString = of_alloc(retLength, 1);
for (size_t i = 0; i < length; i++) {
switch (string[i]) {
case '<':
append = "<";
appendLen = 4;
break;
|
|
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
OFString *ret;
string = self.UTF8String;
length = self.UTF8StringLength;
j = 0;
retLength = length;
retCString = OFAllocMemory(retLength, 1);
for (size_t i = 0; i < length; i++) {
switch (string[i]) {
case '<':
append = "<";
appendLen = 4;
break;
|
71
72
73
74
75
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
|
default:
append = NULL;
appendLen = 0;
}
if (append != NULL) {
@try {
retCString = of_realloc(retCString, 1,
retLength + appendLen);
} @catch (id e) {
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 {
free(retCString);
}
return ret;
}
@end
|
|
|
|
|
71
72
73
74
75
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
|
default:
append = NULL;
appendLen = 0;
}
if (append != NULL) {
@try {
retCString = OFResizeMemory(retCString, 1,
retLength + appendLen);
} @catch (id e) {
OFFreeMemory(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 {
OFFreeMemory(retCString);
}
return ret;
}
@end
|