ObjFW  Diff

Differences From Artifact [844da0afa5]:

To Artifact [1a2c0cda4c]:


26
27
28
29
30
31
32


33
34
35
36
37
38
39
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41







+
+







#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef OF_GNU_RUNTIME
# import <objc/sarray.h>
#endif

#import "atomic.h"

struct pre_ivar {
	void   **memchunks;
	size_t memchunks_size;
	size_t retain_count;
};

/* Hopefully no arch needs more than 16 bytes padding */
469
470
471
472
473
474
475
476

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

489
490
491
492
493
494
495
471
472
473
474
475
476
477

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

490
491
492
493
494
495
496
497







-
+











-
+








	@throw [OFMemoryNotPartOfObjectException newWithClass: isa
						      pointer: ptr];
}

- retain
{
	PRE_IVAR->retain_count++;
	of_atomic_inc32(&PRE_IVAR->retain_count);

	return self;
}

- (size_t)retainCount
{
	return PRE_IVAR->retain_count;
}

- (void)release
{
	if (!--PRE_IVAR->retain_count)
	if (!of_atomic_dec32(&PRE_IVAR->retain_count))
		[self dealloc];
}

- autorelease
{
	[OFAutoreleasePool addObjectToTopmostPool: self];