gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementation of CFBridgingRelease() on GNUstep


From: Daniel Ferreira (theiostream)
Subject: Re: Implementation of CFBridgingRelease() on GNUstep
Date: Thu, 1 Jun 2017 13:49:10 -0300

CFBridgingRetain() and CFBridgingRelease() should to exactly what the
__bridge_retained and __bridge_transfer compiler directives do, so an
insight on how the libobjc2 ARC runtime handles this case will
probably give us an answer.

However, according to Mike Ash[1] in an article from 2011 on the dawn of ARC,

> CFStringRef valueCF = CFPreferencesCopyAppValue(CFSTR("someKey"), 
> CFSTR("com.company.someapp"));
> NSString *value = (__bridge NSString *)valueCF;
> CFRelease(valueCF);
> [self useValue: value];

is functionally equivalent to:

> NSString *value = 
> CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("someKey"), 
> CFSTR("com.company.someapp")));
> [self useValue: value];

So it seems to me logically that the behavior of CFBridgingRelease()
should be that of reducing the reference count of the object but not
deallocate it if it reaches zero, assuming ARC will immediately add
one to the reference count when the CF type becomes an Objective-C
object.

As for CFBridgingRetain(), the same effect will be attained anyway if
we CFRetain() when ARC releases everything on ObjC-land, but I wonder
if it should do anything else.

[1]: 
https://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]