Differences From Artifact [e2d9167ac3]:
- File
src/OFString.m
— part of check-in
[1d44132d96]
at
2009-05-07 11:55:53
on branch trunk
— There is no point in splitWithDelimiter: requiring an OFString.
Plus some code clean up in splitWithDelimiter:. (user: js, size: 3784) [annotate] [blame] [check-ins using]
To Artifact [7666d17f06]:
- File
src/OFString.m
— part of check-in
[1c798ffa3f]
at
2009-05-13 19:39:35
on branch trunk
— Get rid of a @try block in OFString.
This works since we release all pools on top of the pool being released
as well now. (user: js, size: 3666) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
160 161 162 163 164 165 166 | - (OFArray*)splitWithDelimiter: (const char*)delimiter { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *array = nil; size_t delim_len = strlen(delimiter); size_t i, last; | < | | | | | | | | | | | | | | | | | | | | | | > | | | | | | < | < < | | < | | 160 161 162 163 164 165 166 167 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 201 202 203 204 205 | - (OFArray*)splitWithDelimiter: (const char*)delimiter { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *array = nil; size_t delim_len = strlen(delimiter); size_t i, last; array = [OFArray array]; for (i = 0, last = 0; i <= length; i++) { if (OF_UNLIKELY(i == length || !memcmp(string + i, delimiter, delim_len))) { OFString *str; char *tmp; /* * We can't use [self allocWithSize:] here as * self might be a @""-literal. */ if ((tmp = malloc(i - last + 1)) == NULL) @throw [OFNoMemException newWithClass: isa andSize: i - last + 1]; memcpy(tmp, string + last, i - last); tmp[i - last] = '\0'; @try { str = [OFString stringWithCString: tmp]; } @finally { free(tmp); } [array add: str]; [array retain]; [pool releaseObjects]; i += delim_len - 1; last = i + 1; } } [array retain]; [pool release]; return array; } @end |