ObjFW  Check-in [bfb7745f95]

Overview
Comment:Don't create and release a pool in -[enumerateObjectsUsingBlock:].

This would make it impossible to use autoreleased objects after the
block has been executed without manually retaining and releasing them.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bfb7745f9533e44ae8888bab6e948feefbd5c830bdebbfc98e3109d8d730cb7a
User & Date: js on 2011-07-28 20:50:09
Other Links: manifest | tags
Context
2011-07-28
21:31
Add +[elementWithFile:] to OFXMLElement. check-in: 7d5e2ebb80 user: js tags: trunk
20:50
Don't create and release a pool in -[enumerateObjectsUsingBlock:]. check-in: bfb7745f95 user: js tags: trunk
2011-07-26
21:42
Add OFCountedSet. check-in: eb791d09d1 user: js tags: trunk
Changes

Modified src/OFArray.m from [ce913f08f5] to [1f143f64a7].

578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
					       dataArray: array
					mutationsPointer: NULL] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;

	for (i = 0; i < count && !stop; i++) {
		block(cArray[i], i, &stop);
		[pool releaseObjects];
	}

	[pool release];
}

- (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block
{
	OFArray *ret;
	size_t count = [array count];
	id *tmp = [self allocMemoryForNItems: count







<




|

<
<
<
<







578
579
580
581
582
583
584

585
586
587
588
589
590




591
592
593
594
595
596
597
					       dataArray: array
					mutationsPointer: NULL] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{

	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;

	for (i = 0; i < count && !stop; i++)
		block(cArray[i], i, &stop);




}

- (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block
{
	OFArray *ret;
	size_t count = [array count];
	id *tmp = [self allocMemoryForNItems: count

Modified src/OFDictionary.m from [95bb1cf3d0] to [39169fee1e].

730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
	return i;
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	size_t i;
	BOOL stop = NO;

	for (i = 0; i < size && !stop; i++) {
		if (data[i] != NULL && data[i] != DELETED) {
			block(data[i]->key, data[i]->object, &stop);
			[pool releaseObjects];
		}
	}

	[pool release];
}

- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,







<



|
|

<
<
<
<
<







730
731
732
733
734
735
736

737
738
739
740
741
742





743
744
745
746
747
748
749
	return i;
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{

	size_t i;
	BOOL stop = NO;

	for (i = 0; i < size && !stop; i++)
		if (data[i] != NULL && data[i] != DELETED)
			block(data[i]->key, data[i]->object, &stop);





}

- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,