ObjFW  Check-in [dbd79d0747]

Overview
Comment:Fix reference counting for blocks.

Hopefully, there is no weird situation left where it fails...

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dbd79d07473cfca7a194da5a19925f38c308677421e78ee0559a621ecad1db0c
User & Date: js on 2011-07-18 03:01:36
Other Links: manifest | tags
Context
2011-07-18
22:53
Add OFSet and OFMutableSet. check-in: 8df328d503 user: js tags: trunk
03:01
Fix reference counting for blocks. check-in: dbd79d0747 user: js tags: trunk
2011-07-17
16:38
Remove -[containsObjectIdenticalTo:] from OFCopying. check-in: 8ff55bf218 user: js tags: trunk
Changes

Modified src/OFBlock.m from [ff454a2522] to [0147efccdf].

293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
293
294
295
296
297
298
299



300
301
302
303
304
305
306







-
-
-







			}

			if (src->forwarding == src)
				src->forwarding = *dst;

			memcpy(*dst, src, src->size);

			/* src->forwarding points to us -> that's a reference */
			(*dst)->flags++;

			if (src->size >= sizeof(of_block_byref_t))
				src->byref_keep(*dst, src);
		} else
			*dst = src;

		(*dst)->flags++;
		break;
466
467
468
469
470
471
472

473

474
475
476
477
478
479
480
463
464
465
466
467
468
469
470

471
472
473
474
475
476
477
478







+
-
+







		    OF_BLOCK_REFCOUNT_MASK;

	return OF_RETAIN_COUNT_MAX;
}

- (void)release
{
	if (isa == (Class)&_NSConcreteMallocBlock)
	Block_release(self);
		Block_release(self);
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */

Modified tests/OFBlockTests.m from [10c79b74fc] to [0518f13692].

64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
79
80
81
64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81







-
+










	    (m = [[s copy] autorelease]) &&
	    [m class] == objc_getClass("OFMallocBlock") &&
	    [m isKindOfClass: [OFBlock class]])

	TEST(@"Copying a global block", (id)g == [[g copy] autorelease])

	TEST(@"Copying a malloc block",
	    (id)m == [[m copy] autorelease] && [m retainCount] == 2)
	    (id)m == [m copy] && [m retainCount] == 2)

	TEST(@"Autorelease a stack block", R([s autorelease]))

	TEST(@"Autorelease a global block", R([g autorelease]))

	TEST(@"Autorelease a malloc block", R([m autorelease]))

	[pool drain];
}
@end