typedef __typeof(sizeof(int)) size_t;
#define HAS_ARC __has_feature(objc_arc)
typedef unsigned long long CFOptionFlags;
typedef signed long long CFIndex;
typedef CFIndex CFPropertyListFormat; enum {
kCFPropertyListOpenStepFormat = 1,
kCFPropertyListXMLFormat_v1_0 = 100,
kCFPropertyListBinaryFormat_v1_0 = 200
};
typedef const struct __CFAllocator * CFAllocatorRef;
extern const CFAllocatorRef kCFAllocatorDefault;
typedef struct __CFDictionary * CFDictionaryRef;
typedef struct __CFError * CFErrorRef;
typedef struct __CFDataRef * CFDataRef;
typedef void * CFPropertyListRef;
CFPropertyListRef CFPropertyListCreateWithData(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error);
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSDictionary;
@class NSData;
@class NSString;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
- (oneway void)release;
- (id)autorelease;
- (NSString *)description;
- (id)init;
@end
@interface NSObject <NSObject> {}
+ (id)allocWithZone:(NSZone *)zone;
+ (id)alloc;
+ (id)new;
- (void)dealloc;
@end
@interface NSDictionary : NSObject
@end
#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
@protocol OS_dispatch_object
@end
@protocol OS_dispatch_data <OS_dispatch_object>
@end
@protocol OS_dispatch_queue <OS_dispatch_object>
@end
typedef NSObject<OS_dispatch_object> *dispatch_object_t;
typedef NSObject<OS_dispatch_data> *dispatch_data_t;
typedef NSObject<OS_dispatch_queue> *dispatch_queue_t;
typedef void (^dispatch_block_t)(void);
dispatch_queue_t dispatch_get_main_queue(void);
DISPATCH_RETURNS_RETAINED dispatch_data_t
dispatch_data_create(const void *buffer, size_t size,
dispatch_queue_t _Nullable queue,
dispatch_block_t _Nullable destructor);
void _dispatch_object_validate(dispatch_object_t object);
#define dispatch_retain(object) \
__extension__({ dispatch_object_t _o = (object); \
_dispatch_object_validate(_o); \
(void)[_o retain]; })
#define dispatch_release(object) \
__extension__({ dispatch_object_t _o = (object); \
_dispatch_object_validate(_o); \
[_o release]; })
@interface SomeClass
@end
@implementation SomeClass
- (NSDictionary *)copyTestWithBridgeReturningRetainable:(NSData *)plistData {
CFErrorRef error;
CFDictionaryRef testDict = CFPropertyListCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)plistData, 0, 0, &error);
#if HAS_ARC
#endif
return (__bridge NSDictionary *)testDict;
#if HAS_ARC
#endif
}
- (NSDictionary *)copyTestWithoutBridgeReturningRetainable:(NSData *)plistData {
NSDictionary *testDict = [[NSDictionary alloc] init];
return testDict; }
- (NSDictionary *)copyTestWithBridgeTransferReturningRetainable:(NSData *)plistData {
CFErrorRef error;
CFDictionaryRef testDict = CFPropertyListCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)plistData, 0, 0, &error);
return (__bridge_transfer NSDictionary *)testDict; #if !HAS_ARC
#endif
}
- (CFDictionaryRef)copyTestReturningCoreFoundation:(NSData *)plistData {
CFErrorRef error;
CFDictionaryRef testDict = CFPropertyListCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)plistData, 0, 0, &error);
return testDict;
}
@end
int buf[1024];
void libdispatch_leaked_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
}
#if !HAS_ARC
#endif
void libdispatch_dispatch_released_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
dispatch_release(data); #endif
}
void libdispatch_objc_released_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
[data release]; #endif
}
void libdispatch_leaked_retained_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
dispatch_retain(data);
[data release];
#endif
}
#if !HAS_ARC
#endif