ObjFW  Check-in [a0b7eb7a66]

Overview
Comment:Autorelease array returned in -[splitWithDelimiter] properly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a0b7eb7a660dbd6e53c96e46565ef9dc80394019a2312bf080e562909c75ef5b
User & Date: js on 2009-06-10 00:02:01
Other Links: manifest | tags
Context
2009-06-10
15:31
Add +[setImplementation:forMethod:]. check-in: b10efe7b2b user: js tags: trunk
00:02
Autorelease array returned in -[splitWithDelimiter] properly. check-in: a0b7eb7a66 user: js tags: trunk
2009-06-09
23:33
Return plugins autoreleased in OFPlugin. check-in: 5df8f61fe4 user: js tags: trunk
Changes

Modified src/OFString.m from [16153df8cd] to [67f5019bf6].

307
308
309
310
311
312
313
314

315
316
317
318
319
320
321

322
323
324
325
326
327
328
329
330
331
332
333
334
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321
322
323
324
325
326


327
328
329
330
331
332
333







-
+







+




-
-







	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFArray*)splitWithDelimiter: (OFString*)delimiter
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool;
	OFArray *array = nil;
	OFString *str;
	const char *delim = [delimiter cString];
	size_t delim_len = [delimiter length];
	size_t i, last;

	array = [OFMutableArray array];
	pool = [[OFAutoreleasePool alloc] init];

	if (delim_len > length) {
		str = [[self copy] autorelease];
		[array addObject: str];

		[array retain];
		[pool release];

		return array;
	}

	for (i = 0, last = 0; i <= length - delim_len; i++) {
		char *tmp;
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
348
349
350
351
352
353
354

355
356
357
358
359
360
361

362
363
364
365
366
367
368







-







-







		@try {
			str = [OFString stringWithCString: tmp];
		} @finally {
			free(tmp);
		}

		[array addObject: str];
		[array retain];
		[pool releaseObjects];

		i += delim_len - 1;
		last = i + 1;
	}
	[array addObject: [OFString stringWithCString: string + last]];

	[array retain];
	[pool release];

	return array;
}

- setToCString: (const char*)str
{