ObjFW  Diff

Differences From Artifact [415ea37dd0]:

To Artifact [7ae92c5eec]:


117
118
119
120
121
122
123
124




125
126
127
128
129
130
131
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
134







-
+
+
+
+







	}

	((struct pre_ivar*)instance)->memchunks = NULL;
	((struct pre_ivar*)instance)->memchunks_size = 0;
	((struct pre_ivar*)instance)->retain_count = 1;

#ifndef OF_ATOMIC_OPS
	of_spinlock_new(&((struct pre_ivar*)instance)->retain_spinlock);
	if (!of_spinlock_new(&((struct pre_ivar*)instance)->retain_spinlock)) {
		free(instance);
		@throw [OFInitializationFailedException newWithClass: self];
	}
#endif

	instance = (OFObject*)((char*)instance + PRE_IVAR_ALIGN);
	memset(instance, 0, isize);
	instance->isa = self;

	return instance;
497
498
499
500
501
502
503
504

505
506

507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525

526
527

528
529
530
531
532
533
534
500
501
502
503
504
505
506

507
508

509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527

528
529

530
531
532
533
534
535
536
537







-
+

-
+


















-
+

-
+







}

- retain
{
#ifdef OF_ATOMIC_OPS
	of_atomic_inc32(&PRE_IVAR->retain_count);
#else
	of_spinlock_lock(&PRE_IVAR->retain_spinlock);
	assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock));
	PRE_IVAR->retain_count++;
	of_spinlock_unlock(&PRE_IVAR->retain_spinlock);
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));
#endif

	return self;
}

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

- (void)release
{
#ifdef OF_ATOMIC_OPS
	if (!of_atomic_dec32(&PRE_IVAR->retain_count))
		[self dealloc];
#else
	int32_t c;

	of_spinlock_lock(&PRE_IVAR->retain_spinlock);
	assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock));
	c = --PRE_IVAR->retain_count;
	of_spinlock_unlock(&PRE_IVAR->retain_spinlock);
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));

	if (!c)
		[self dealloc];
#endif
}

- autorelease