ObjFW  Check-in [ab14af79d2]

Overview
Comment:OFMapTable: Improve enumeration mutation detection
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ab14af79d2501fad9891a484fbebd32f07bed7507d3bb70c7b8e93997d210826
User & Date: js on 2024-02-18 13:53:09
Other Links: manifest | tags
Context
2024-02-18
14:09
Update ChangeLog for 1.0.9 check-in: d080eb08fb user: js tags: trunk
13:53
Merge trunk into branch "objfwtest" check-in: 89869c188f user: js tags: objfwtest
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
22:40
Make sure objects are correctly aligned on Windows check-in: 2547c1c4ce user: js tags: trunk
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
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)) {
			_mutations++;

			_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
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];

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

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