ObjFW  Check-in [2b0bdf3efc]

Overview
Comment:OFMapTable: Improve enumeration mutation detection
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.0
Files: files | file ages | folders
SHA3-256: 2b0bdf3efce0add5628bc3d339842ebbec4ea10c45a43c3de750050feb482b67
User & Date: js on 2024-02-18 13:53:23
Other Links: branch diff | manifest | tags
Context
2024-02-18
14:04
Update ChangeLog for 1.0.9 check-in: d439625efa user: js tags: 1.0
13:53
OFMapTable: Improve enumeration mutation detection check-in: 2b0bdf3efc user: js tags: 1.0
13:53
OFMapTable: Improve enumeration mutation detection check-in: ab14af79d2 user: js tags: trunk
2024-02-13
21:13
Fix -[OFDictionary initWithKey:arguments:] check-in: 3b6f5b8030 user: js tags: 1.0
Changes

Modified src/OFMapTable.m from [3e827255d3] to [77fd4c4f10].

468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483

484
485
486
487
488
489
490

	for (i = rotatedHash & (_capacity - 1);
	    i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deletedBucket)
			continue;

		if (_keyFunctions.equal(_buckets[i]->key, key)) {
			_mutations++;

			_keyFunctions.release(_buckets[i]->key);
			_objectFunctions.release(_buckets[i]->object);

			OFFreeMemory(_buckets[i]);
			_buckets[i] = &deletedBucket;

			_count--;

			resizeForCount(self, _count);

			return;
		}
	}

	if (i < last)







<
<







>







468
469
470
471
472
473
474


475
476
477
478
479
480
481
482
483
484
485
486
487
488
489

	for (i = rotatedHash & (_capacity - 1);
	    i < last && _buckets[i] != NULL; i++) {
		if (_buckets[i] == &deletedBucket)
			continue;

		if (_keyFunctions.equal(_buckets[i]->key, key)) {


			_keyFunctions.release(_buckets[i]->key);
			_objectFunctions.release(_buckets[i]->object);

			OFFreeMemory(_buckets[i]);
			_buckets[i] = &deletedBucket;

			_count--;
			_mutations++;
			resizeForCount(self, _count);

			return;
		}
	}

	if (i < last)
614
615
616
617
618
619
620



621
622
623
624
625
626
627
628
629
630
631
632
633
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock: (OFMapTableEnumerationBlock)block
{
	bool stop = false;
	unsigned long mutations = _mutations;

	for (size_t i = 0; i < _capacity && !stop; i++) {



		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithObject: self];

		if (_buckets[i] != NULL && _buckets[i] != &deletedBucket)
			block(_buckets[i]->key, _buckets[i]->object, &stop);
	}
}

- (void)replaceObjectsUsingBlock: (OFMapTableReplaceBlock)block
{
	unsigned long mutations = _mutations;








>
>
>



<
<
<







613
614
615
616
617
618
619
620
621
622
623
624
625



626
627
628
629
630
631
632
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock: (OFMapTableEnumerationBlock)block
{
	bool stop = false;
	unsigned long mutations = _mutations;

	for (size_t i = 0; i < _capacity && !stop; i++) {
		if (_buckets[i] != NULL && _buckets[i] != &deletedBucket)
			block(_buckets[i]->key, _buckets[i]->object, &stop);

		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithObject: self];



	}
}

- (void)replaceObjectsUsingBlock: (OFMapTableReplaceBlock)block
{
	unsigned long mutations = _mutations;