Overview
Comment: | Get rid of a @try block in OFString.
This works since we release all pools on top of the pool being released |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1c798ffa3fb6da58ed3eccdeefbe121c |
User & Date: | js on 2009-05-13 19:39:35 |
Other Links: | manifest | tags |
Context
2009-05-13
| ||
19:49 | There's no need for + initialize to return anything. check-in: 917188fdcc user: js tags: trunk | |
19:39 | Get rid of a @try block in OFString. check-in: 1c798ffa3f user: js tags: trunk | |
17:58 | Also release pools that are on top of the pool being released. check-in: 4f4f619d84 user: js tags: trunk | |
Changes
Modified src/OFString.m from [e2d9167ac3] to [7666d17f06].
︙ | ︙ | |||
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 |