[clang-format] Reformat all c/cpp/objc sources with clang-format

Reviewed By: jul

Differential Revision: https://phabricator.fb.com/D2953843
master
Andrzej Kotulski 9 years ago committed by Sam Blackshear
parent c82a4c1cc1
commit 4584f7f6fc

@ -9,13 +9,13 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface Hello: NSObject @interface Hello : NSObject
@property NSString* s; @property NSString* s;
@end @end
@implementation Hello @implementation Hello
NSString* m() { NSString* m() {
Hello* hello = nil; Hello* hello = nil;
return hello->_s; return hello->_s;
} }
@end @end

@ -7,17 +7,17 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/select.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/select.h>
#include <unistd.h> #include <unistd.h>
struct Person { struct Person {
@ -27,26 +27,23 @@ struct Person {
}; };
int simple_null_pointer() { int simple_null_pointer() {
struct Person *max = 0; struct Person* max = 0;
return max->age; return max->age;
} }
struct Person *Person_create(int age, int height, int weight) { struct Person* Person_create(int age, int height, int weight) {
struct Person *who = 0; struct Person* who = 0;
return who; return who;
} }
int get_age(struct Person *who) { int get_age(struct Person* who) { return who->age; }
return who->age;
}
int null_pointer_interproc() { int null_pointer_interproc() {
struct Person *joe = Person_create(32, 64, 140); struct Person* joe = Person_create(32, 64, 140);
return get_age(joe); return get_age(joe);
} }
void fileNotClosed() void fileNotClosed() {
{
int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd != -1) { if (fd != -1) {
char buffer[256]; char buffer[256];
@ -56,14 +53,15 @@ void fileNotClosed()
} }
void simple_leak() { void simple_leak() {
int *p; int* p;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
} }
void common_realloc_leak() { void common_realloc_leak() {
int *p, *q; int *p, *q;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
q = (int*) realloc(p, sizeof(int) * 42); q = (int*)realloc(p, sizeof(int) * 42);
// if realloc fails, then p becomes unreachable // if realloc fails, then p becomes unreachable
if (q != NULL) free(q); if (q != NULL)
free(q);
} }

@ -10,6 +10,6 @@
#include <stdlib.h> #include <stdlib.h>
void test() { void test() {
int *s = NULL; int* s = NULL;
*s = 42; *s = 42;
} }

@ -14,10 +14,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate> @interface AppDelegate : UIResponder<UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property(strong, nonatomic) UIWindow* window;
@end @end

@ -22,63 +22,75 @@
@implementation AppDelegate @implementation AppDelegate
-(void) memory_leak_bug { - (void)memory_leak_bug {
CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL); CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL);
} }
-(void) resource_leak_bug { - (void)resource_leak_bug {
FILE *fp; FILE* fp;
fp=fopen("c:\\test.txt", "r"); fp = fopen("c:\\test.txt", "r");
} }
-(void) parameter_not_null_checked_block_bug:(void (^)())callback { - (void)parameter_not_null_checked_block_bug:(void (^)())callback {
callback(); callback();
} }
-(NSArray*) npe_in_array_literal_bug { - (NSArray*)npe_in_array_literal_bug {
NSString *str = nil; NSString* str = nil;
return @[@"horse", str, @"dolphin"]; return @[ @"horse", str, @"dolphin" ];
} }
-(NSArray*) premature_nil_termination_argument_bug { - (NSArray*)premature_nil_termination_argument_bug {
NSString *str = nil; NSString* str = nil;
return [NSArray arrayWithObjects: @"horse", str, @"dolphin", nil]; return [NSArray arrayWithObjects:@"horse", str, @"dolphin", nil];
} }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication*)application
// Override point for customization after application launch. didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
Hello *hello = [Hello new]; // Override point for customization after application launch.
[hello null_dereference_bug]; Hello* hello = [Hello new];
[self memory_leak_bug]; [hello null_dereference_bug];
[self resource_leak_bug]; [self memory_leak_bug];
[hello parameter_not_null_checked_bug:nil]; [self resource_leak_bug];
[self parameter_not_null_checked_block_bug:nil]; [hello parameter_not_null_checked_bug:nil];
[hello ivar_not_nullable_bug:nil]; [self parameter_not_null_checked_block_bug:nil];
[self npe_in_array_literal_bug]; [hello ivar_not_nullable_bug:nil];
[self premature_nil_termination_argument_bug]; [self npe_in_array_literal_bug];
return YES; [self premature_nil_termination_argument_bug];
return YES;
} }
- (void)applicationWillResignActive:(UIApplication *)application { - (void)applicationWillResignActive:(UIApplication*)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // This can occur for certain types of temporary interruptions (such as an
// incoming phone call or SMS message) or when the user quits the application
// and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down
// OpenGL ES frame rates. Games should use this method to pause the game.
} }
- (void)applicationDidEnterBackground:(UIApplication *)application { - (void)applicationDidEnterBackground:(UIApplication*)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // Use this method to release shared resources, save user data, invalidate
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. // timers, and store enough application state information to restore your
// application to its current state in case it is terminated later.
// If your application supports background execution, this method is called
// instead of applicationWillTerminate: when the user quits.
} }
- (void)applicationWillEnterForeground:(UIApplication *)application { - (void)applicationWillEnterForeground:(UIApplication*)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. // Called as part of the transition from the background to the inactive state;
// here you can undo many of the changes made on entering the background.
} }
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication*)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // Restart any tasks that were paused (or not yet started) while the
// application was inactive. If the application was previously in the
// background, optionally refresh the user interface.
} }
- (void)applicationWillTerminate:(UIApplication *)application { - (void)applicationWillTerminate:(UIApplication*)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // Called when the application is about to terminate. Save data if
// appropriate. See also applicationDidEnterBackground:.
} }
@end @end

@ -16,15 +16,15 @@
@interface Hello : NSObject @interface Hello : NSObject
@property (strong) NSString* s; @property(strong) NSString* s;
@property (strong) Hello* hello; @property(strong) Hello* hello;
-(Hello*) return_hello; - (Hello*)return_hello;
-(NSString*) null_dereference_bug; - (NSString*)null_dereference_bug;
-(NSString*) ivar_not_nullable_bug:(Hello*) hello; - (NSString*)ivar_not_nullable_bug:(Hello*)hello;
-(NSString*) parameter_not_null_checked_bug:(Hello*) hello; - (NSString*)parameter_not_null_checked_bug:(Hello*)hello;
@end @end

@ -12,28 +12,28 @@
// HelloWorldApp // HelloWorldApp
// //
#import <Foundation/Foundation.h>
#import "Hello.h" #import "Hello.h"
#import <Foundation/Foundation.h>
@implementation Hello @implementation Hello
-(Hello*) return_hello { - (Hello*)return_hello {
return [Hello new]; return [Hello new];
} }
-(NSString*) null_dereference_bug { - (NSString*)null_dereference_bug {
Hello *hello = nil; Hello* hello = nil;
return hello->_s; return hello->_s;
} }
-(NSString*) ivar_not_nullable_bug:(Hello*) hello { - (NSString*)ivar_not_nullable_bug:(Hello*)hello {
Hello* ret_hello = [hello->_hello return_hello]; Hello* ret_hello = [hello->_hello return_hello];
return ret_hello->_s; return ret_hello->_s;
} }
-(NSString*) parameter_not_null_checked_bug:(Hello*) hello { - (NSString*)parameter_not_null_checked_bug:(Hello*)hello {
Hello *ret_hello = [hello return_hello]; Hello* ret_hello = [hello return_hello];
return ret_hello->_s; return ret_hello->_s;
} }
@end @end

@ -16,6 +16,4 @@
@interface ViewController : UIViewController @interface ViewController : UIViewController
@end @end

@ -21,13 +21,13 @@
@implementation ViewController @implementation ViewController
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
@end @end

@ -12,11 +12,12 @@
// HelloWorldApp // HelloWorldApp
// //
#import <UIKit/UIKit.h>
#import "AppDelegate.h" #import "AppDelegate.h"
#import <UIKit/UIKit.h>
int main(int argc, char * argv[]) { int main(int argc, char* argv[]) {
@autoreleasepool { @autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); return UIApplicationMain(
} argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
} }

@ -23,25 +23,27 @@
@implementation HelloWorldAppTests @implementation HelloWorldAppTests
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class. // Put setup code here. This method is called before the invocation of each
// test method in the class.
} }
- (void)tearDown { - (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class. // Put teardown code here. This method is called after the invocation of each
[super tearDown]; // test method in the class.
[super tearDown];
} }
- (void)testExample { - (void)testExample {
// This is an example of a functional test case. // This is an example of a functional test case.
XCTAssert(YES, @"Pass"); XCTAssert(YES, @"Pass");
} }
- (void)testPerformanceExample { - (void)testPerformanceExample {
// This is an example of a performance test case. // This is an example of a performance test case.
[self measureBlock:^{ [self measureBlock:^{
// Put the code you want to measure the time of here. // Put the code you want to measure the time of here.
}]; }];
} }
@end @end

@ -15,41 +15,42 @@
#include <stdlib.h> #include <stdlib.h>
// similar to malloc, but never fails, and returns NULL when size==0 // similar to malloc, but never fails, and returns NULL when size==0
void *g_malloc(size_t size) { void* g_malloc(size_t size) {
if(size==0) return NULL; if (size == 0)
void *res = malloc(size); return NULL;
void* res = malloc(size);
INFER_EXCLUDE_CONDITION(!res); INFER_EXCLUDE_CONDITION(!res);
return res; return res;
} }
// modelled as free // modelled as free
void g_free(void *ptr) { void g_free(void* ptr) { free(ptr); }
free(ptr);
}
void *g_realloc(void *ptr, size_t size) { void* g_realloc(void* ptr, size_t size) {
if(size==0) { // return NULL and free ptr unless it is NULL if (size == 0) { // return NULL and free ptr unless it is NULL
if(ptr) free(ptr); if (ptr)
free(ptr);
return NULL; return NULL;
} }
int old_size; int old_size;
old_size = __get_array_size(ptr); // force ptr to be an array old_size = __get_array_size(ptr); // force ptr to be an array
int can_enlarge; // nondeterministically choose whether the current block can be enlarged int can_enlarge; // nondeterministically choose whether the current block can
if(can_enlarge) { // be enlarged
if (can_enlarge) {
__set_array_size(ptr, size); // enlarge the block __set_array_size(ptr, size); // enlarge the block
return ptr; return ptr;
} }
int *newblock = (int*)malloc(size); int* newblock = (int*)malloc(size);
if(newblock) { if (newblock) {
free(ptr); free(ptr);
return newblock; return newblock;
} } else
else exit(0); // assume that new allocation does not fail exit(0); // assume that new allocation does not fail
} }
// simply return object, and assume it is not NULL // simply return object, and assume it is not NULL
void *gtk_type_check_object_cast(void *object, void *cast_type) { void* gtk_type_check_object_cast(void* object, void* cast_type) {
if(!object) exit(0); if (!object)
exit(0);
return object; return object;
} }

@ -43,8 +43,8 @@ unsigned long int __infer_nondet_unsigned_long_int() {
} }
// model returning an arbitrary (nondeterministic) pointer // model returning an arbitrary (nondeterministic) pointer
void *__infer_nondet_ptr() { void* __infer_nondet_ptr() {
void *res; void* res;
return res; return res;
} }
@ -92,7 +92,10 @@ long infer__builtin_expect(long e, long x) {
} }
} }
void *infer__builtin___memset_chk(void *dest, int val, unsigned long len, unsigned long dstlen) { void* infer__builtin___memset_chk(void* dest,
int val,
unsigned long len,
unsigned long dstlen) {
INFER_EXCLUDE_CONDITION(dstlen < len); INFER_EXCLUDE_CONDITION(dstlen < len);
return dest; return dest;
} }

@ -10,8 +10,8 @@
// builtins to be used to model library functions // builtins to be used to model library functions
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
// model returning an arbitrary (nondeterministic) short // model returning an arbitrary (nondeterministic) short
@ -30,7 +30,7 @@ long long int __infer_nondet_long_long_int();
unsigned long int __infer_nondet_unsigned_long_int(); unsigned long int __infer_nondet_unsigned_long_int();
// model returning an arbitrary (nondeterministic) pointer // model returning an arbitrary (nondeterministic) pointer
void *__infer_nondet_ptr(); void* __infer_nondet_ptr();
// model returning an arbitrary (nondeterministic) float // model returning an arbitrary (nondeterministic) float
float __infer_nondet_float(); float __infer_nondet_float();
@ -51,17 +51,21 @@ time_t __infer_nondet_time_t();
clock_t __infer_nondet_clock_t(); clock_t __infer_nondet_clock_t();
// assume that the cond is false // assume that the cond is false
// and add any constraints to the precondition so that cond is false, if possible // and add any constraints to the precondition so that cond is false, if
#define INFER_EXCLUDE_CONDITION(cond) if (cond) while(1) // possible
#define INFER_EXCLUDE_CONDITION(cond) \
if (cond) \
while (1)
// builtin: force arr to be an array and return the size // builtin: force arr to be an array and return the size
extern size_t __get_array_size(const void *arr); extern size_t __get_array_size(const void* arr);
// builtin: change the attribute of ret to a file attribute // builtin: change the attribute of ret to a file attribute
extern void __set_file_attribute(void *ret); extern void __set_file_attribute(void* ret);
// builtin: change the size of the array to size // builtin: change the size of the array to size
extern void __set_array_size(void *ptr, size_t size); extern void __set_array_size(void* ptr, size_t size);
// builtin: set the flag to the given value for the procedure where this call appears // builtin: set the flag to the given value for the procedure where this call
extern void __infer_set_flag(char *flag, char *value); // appears
extern void __infer_set_flag(char* flag, char* value);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -19,126 +19,112 @@
#define USE_CPP_OVERLOADS #define USE_CPP_OVERLOADS
#endif #endif
#include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#define restrict #define restrict
#ifdef _WIN32 #ifdef _WIN32
#define CLIBCALL __cdecl #define CLIBCALL __cdecl
#else #else
#define CLIBCALL #define CLIBCALL
#endif #endif
int CLIBCALL fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...); // builtin: modeled internally int CLIBCALL fwscanf(FILE* restrict stream,
int CLIBCALL swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...); // builtin: modeled internally const wchar_t* restrict format,
int CLIBCALL vfwscanf(FILE * restrict stream, const wchar_t * restrict format, va_list arg); // builtin: modeled internally ...); // builtin: modeled internally
int CLIBCALL vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg); // builtin: modeled internally int CLIBCALL swscanf(const wchar_t* restrict s,
int CLIBCALL vwscanf(const wchar_t * restrict format, va_list arg); // builtin: modeled internally const wchar_t* restrict format,
int CLIBCALL wscanf(const wchar_t * restrict format, ...); // builtin: modeled internally ...); // builtin: modeled internally
int CLIBCALL vfwscanf(FILE* restrict stream,
const wchar_t* restrict format,
wint_t CLIBCALL btowc(int c) va_list arg); // builtin: modeled internally
{ int CLIBCALL vswscanf(const wchar_t* restrict s,
return __infer_nondet_int(); const wchar_t* restrict format,
} va_list arg); // builtin: modeled internally
int CLIBCALL vwscanf(const wchar_t* restrict format,
wint_t CLIBCALL fgetwc(FILE *stream) va_list arg); // builtin: modeled internally
{ int CLIBCALL wscanf(const wchar_t* restrict format,
return __infer_nondet_int(); ...); // builtin: modeled internally
}
wint_t CLIBCALL btowc(int c) { return __infer_nondet_int(); }
wint_t CLIBCALL fgetwc(FILE* stream) { return __infer_nondet_int(); }
// modelled like fgets // modelled like fgets
wchar_t * CLIBCALL fgetws(wchar_t * restrict s, int n, FILE * restrict stream) wchar_t* CLIBCALL fgetws(wchar_t* restrict s, int n, FILE* restrict stream) {
{ return (wchar_t*)fgets((char*)s, n, stream);
return (wchar_t *) fgets((char *)s, n, stream);
} }
wint_t CLIBCALL fputwc(wchar_t c, FILE *stream) wint_t CLIBCALL fputwc(wchar_t c, FILE* stream) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
// modeled using fputs // modeled using fputs
int CLIBCALL fputws(const wchar_t * restrict s, FILE * restrict stream) int CLIBCALL fputws(const wchar_t* restrict s, FILE* restrict stream) {
{ return fputs((char*)s, stream);
return fputs((char *)s, stream);
} }
int CLIBCALL fwide(FILE *stream, int mode) int CLIBCALL fwide(FILE* stream, int mode) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL fwprintf(FILE * restrict stream, const wchar_t * restrict format, ...) int CLIBCALL fwprintf(FILE* restrict stream,
{ const wchar_t* restrict format,
...) {
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
return res; return res;
} }
#ifdef getwc #ifdef getwc
#undef getwc // disable expansion of getwc #undef getwc // disable expansion of getwc
#endif #endif
wint_t CLIBCALL getwc(FILE *stream) wint_t CLIBCALL getwc(FILE* stream) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
#ifdef getwchar #ifdef getwchar
#undef getwchar // disable expansion of getwchar #undef getwchar // disable expansion of getwchar
#endif #endif
wint_t CLIBCALL getwchar() wint_t CLIBCALL getwchar() { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
size_t CLIBCALL mbrlen(const char * restrict s, size_t n, mbstate_t * restrict ps) size_t CLIBCALL mbrlen(const char* restrict s,
{ size_t n,
mbstate_t* restrict ps) {
return __infer_nondet_int(); return __infer_nondet_int();
} }
size_t CLIBCALL mbrtowc(wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps) size_t CLIBCALL mbrtowc(wchar_t* restrict pwc,
{ const char* restrict s,
size_t n,
mbstate_t* restrict ps) {
return __infer_nondet_int(); return __infer_nondet_int();
} }
int CLIBCALL mbsinit(const mbstate_t *ps) int CLIBCALL mbsinit(const mbstate_t* ps) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
size_t CLIBCALL mbsrtowcs(wchar_t * restrict dst, const char ** restrict src, size_t len, mbstate_t * restrict ps) size_t CLIBCALL mbsrtowcs(wchar_t* restrict dst,
{ const char** restrict src,
size_t len,
mbstate_t* restrict ps) {
return __infer_nondet_int(); return __infer_nondet_int();
} }
#ifdef putwc #ifdef putwc
#undef putwc // disable expansion of putwc #undef putwc // disable expansion of putwc
#endif #endif
wint_t CLIBCALL putwc(wchar_t c, FILE *stream) wint_t CLIBCALL putwc(wchar_t c, FILE* stream) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
#ifdef putwchar #ifdef putwchar
#undef putwchar // disable expansion of putwchar #undef putwchar // disable expansion of putwchar
#endif #endif
wint_t CLIBCALL putwchar(wchar_t c) wint_t CLIBCALL putwchar(wchar_t c) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
// s must be allocated // s must be allocated
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...) int CLIBCALL swprintf(wchar_t* restrict s,
{ size_t n,
const wchar_t* restrict format,
...) {
int res; int res;
int size1; int size1;
size1 = __get_array_size(s); size1 = __get_array_size(s);
@ -147,14 +133,12 @@ int CLIBCALL swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict f
return res; return res;
} }
wint_t CLIBCALL ungetwc(wint_t c, FILE *stream) wint_t CLIBCALL ungetwc(wint_t c, FILE* stream) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list arg) int CLIBCALL vfwprintf(FILE* restrict stream,
{ const wchar_t* restrict format,
va_list arg) {
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
@ -162,8 +146,10 @@ int CLIBCALL vfwprintf(FILE * restrict stream, const wchar_t * restrict format,
} }
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg) int CLIBCALL vswprintf(wchar_t* restrict s,
{ size_t n,
const wchar_t* restrict format,
va_list arg) {
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
@ -171,27 +157,26 @@ int CLIBCALL vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict
} }
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL vwprintf(const wchar_t * restrict format, va_list arg) int CLIBCALL vwprintf(const wchar_t* restrict format, va_list arg) {
{
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
return res; return res;
} }
size_t CLIBCALL wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps) size_t CLIBCALL wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps) {
{
return __infer_nondet_int(); return __infer_nondet_int();
} }
size_t CLIBCALL wcsrtombs(char * restrict dst, const wchar_t ** restrict src, size_t len, mbstate_t * restrict ps) size_t CLIBCALL wcsrtombs(char* restrict dst,
{ const wchar_t** restrict src,
size_t len,
mbstate_t* restrict ps) {
return __infer_nondet_int(); return __infer_nondet_int();
} }
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
int CLIBCALL wprintf(const wchar_t * restrict format, ...) int CLIBCALL wprintf(const wchar_t* restrict format, ...) {
{
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
@ -199,41 +184,39 @@ int CLIBCALL wprintf(const wchar_t * restrict format, ...)
} }
// modeled using strcat // modeled using strcat
wchar_t * CLIBCALL wcscat(wchar_t * restrict s1, const wchar_t * restrict s2) wchar_t* CLIBCALL wcscat(wchar_t* restrict s1, const wchar_t* restrict s2) {
{ return (wchar_t*)strcat((char*)s1, (char*)s2);
return (wchar_t *) strcat((char *) s1, (char *) s2);
} }
// modeled using strchr // modeled using strchr
#ifndef USE_CPP_OVERLOADS #ifndef USE_CPP_OVERLOADS
wchar_t * CLIBCALL wcschr(const wchar_t *s, wchar_t c) wchar_t* CLIBCALL wcschr(const wchar_t* s, wchar_t c)
# else #else
const wchar_t * CLIBCALL wcschr(const wchar_t *s, wchar_t c) const wchar_t* CLIBCALL wcschr(const wchar_t* s, wchar_t c) {
{ return wcschr((wchar_t*)s, c);
return wcschr((wchar_t*) s, c);
} }
wchar_t * CLIBCALL wcschr(wchar_t *s, wchar_t c) wchar_t* CLIBCALL wcschr(wchar_t* s, wchar_t c)
#endif #endif
{ {
return (wchar_t *) strchr((char *) s, c); return (wchar_t*)strchr((char*)s, c);
} }
// modeled using strcmp // modeled using strcmp
int CLIBCALL wcscmp(const wchar_t *s1, const wchar_t *s2) int CLIBCALL wcscmp(const wchar_t* s1, const wchar_t* s2) {
{ return strcmp((char*)s1, (char*)s2);
return strcmp((char *) s1, (char *) s2);
} }
// modeled using strcmp // modeled using strcmp
int CLIBCALL wcscoll(const wchar_t *s1, const wchar_t *s2) int CLIBCALL wcscoll(const wchar_t* s1, const wchar_t* s2) {
{ return strcmp((char*)s1, (char*)s2);
return strcmp((char *) s1, (char *) s2);
} }
// return a nondeterministic nonnegative integer // return a nondeterministic nonnegative integer
size_t CLIBCALL wcsftime(wchar_t * restrict s, size_t maxsize,const wchar_t * restrict format, const struct tm * restrict timeptr) size_t CLIBCALL wcsftime(wchar_t* restrict s,
{ size_t maxsize,
const wchar_t* restrict format,
const struct tm* restrict timeptr) {
int res; int res;
res = __infer_nondet_int(); res = __infer_nondet_int();
INFER_EXCLUDE_CONDITION(res < 0); INFER_EXCLUDE_CONDITION(res < 0);
@ -241,178 +224,169 @@ size_t CLIBCALL wcsftime(wchar_t * restrict s, size_t maxsize,const wchar_t * re
} }
// modeled using strcpy // modeled using strcpy
wchar_t * CLIBCALL wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2) wchar_t* CLIBCALL wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2) {
{ return (wchar_t*)strcpy((char*)s1, (char*)s2);
return (wchar_t *) strcpy((char *) s1, (char *) s2);
} }
// modeled using strcmp // modeled using strcmp
size_t CLIBCALL wcscspn(const wchar_t *s1, const wchar_t *s2) size_t CLIBCALL wcscspn(const wchar_t* s1, const wchar_t* s2) {
{ return strcmp((char*)s1, (char*)s2);
return strcmp((char *) s1, (char *) s2);
} }
// modeled using strlen // modeled using strlen
size_t CLIBCALL wcslen(const wchar_t *s) size_t CLIBCALL wcslen(const wchar_t* s) { return strlen((char*)s); }
{
return strlen((char *) s);
}
// modeled using strncat // modeled using strncat
wchar_t * CLIBCALL wcsncat(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) wchar_t* CLIBCALL wcsncat(wchar_t* restrict s1,
{ const wchar_t* restrict s2,
return (wchar_t *) strncat((char *) s1, (char *) s2, n); size_t n) {
return (wchar_t*)strncat((char*)s1, (char*)s2, n);
} }
// modeled using strncmp // modeled using strncmp
int CLIBCALL wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) int CLIBCALL wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n) {
{ return strncmp((char*)s1, (char*)s2, n);
return strncmp((char *) s1, (char *) s2, n);
} }
// modeled using strpbrk // modeled using strpbrk
#ifndef USE_CPP_OVERLOADS #ifndef USE_CPP_OVERLOADS
wchar_t * CLIBCALL wcspbrk(const wchar_t *s1, const wchar_t *s2) wchar_t* CLIBCALL wcspbrk(const wchar_t* s1, const wchar_t* s2)
#else #else
const wchar_t * CLIBCALL wcspbrk(const wchar_t *s1, const wchar_t *s2) const wchar_t* CLIBCALL wcspbrk(const wchar_t* s1, const wchar_t* s2) {
{ return wcspbrk((wchar_t*)s1, s2);
return wcspbrk((wchar_t*) s1, s2);
} }
wchar_t * CLIBCALL wcspbrk(wchar_t *s1, const wchar_t *s2) wchar_t* CLIBCALL wcspbrk(wchar_t* s1, const wchar_t* s2)
#endif #endif
{ {
return (wchar_t *) strpbrk((char *) s1, (char *) s2); return (wchar_t*)strpbrk((char*)s1, (char*)s2);
} }
// modeled using strchr // modeled using strchr
#ifndef USE_CPP_OVERLOADS #ifndef USE_CPP_OVERLOADS
wchar_t * CLIBCALL wcsrchr(const wchar_t *s, wchar_t c) wchar_t* CLIBCALL wcsrchr(const wchar_t* s, wchar_t c)
#else #else
const wchar_t * CLIBCALL wcsrchr(const wchar_t *s, wchar_t c) const wchar_t* CLIBCALL wcsrchr(const wchar_t* s, wchar_t c) {
{ return wcsrchr((wchar_t*)s, c);
return wcsrchr((wchar_t*) s, c);
} }
wchar_t * CLIBCALL wcsrchr(wchar_t *s, wchar_t c) wchar_t* CLIBCALL wcsrchr(wchar_t* s, wchar_t c)
#endif #endif
{ {
return (wchar_t *) strchr((char *) s, c); return (wchar_t*)strchr((char*)s, c);
} }
// modeled using strncpy // modeled using strncpy
wchar_t * CLIBCALL wcsncpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) wchar_t* CLIBCALL wcsncpy(wchar_t* restrict s1,
{ const wchar_t* restrict s2,
return (wchar_t *) strncpy((char *) s1, (char *) s2, n); size_t n) {
return (wchar_t*)strncpy((char*)s1, (char*)s2, n);
} }
// modeled using strspn // modeled using strspn
size_t CLIBCALL wcsspn(const wchar_t *s1, const wchar_t *s2) size_t CLIBCALL wcsspn(const wchar_t* s1, const wchar_t* s2) {
{ return strspn((char*)s1, (char*)s2);
return strspn((char *) s1, (char *) s2);
} }
// modeled using strstr // modeled using strstr
#ifndef USE_CPP_OVERLOADS #ifndef USE_CPP_OVERLOADS
wchar_t * CLIBCALL wcsstr(const wchar_t *s1, const wchar_t *s2) wchar_t* CLIBCALL wcsstr(const wchar_t* s1, const wchar_t* s2)
#else #else
const wchar_t * CLIBCALL wcsstr(const wchar_t *s1, const wchar_t *s2) const wchar_t* CLIBCALL wcsstr(const wchar_t* s1, const wchar_t* s2) {
{ return wcsstr((wchar_t*)s1, s2);
return wcsstr((wchar_t*) s1, s2);
} }
wchar_t * CLIBCALL wcsstr(wchar_t *s1, const wchar_t *s2) wchar_t* CLIBCALL wcsstr(wchar_t* s1, const wchar_t* s2)
#endif #endif
{ {
return (wchar_t *) strstr((char *) s1, (char *) s2); return (wchar_t*)strstr((char*)s1, (char*)s2);
} }
int CLIBCALL wctob(wint_t c) int CLIBCALL wctob(wint_t c) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
double CLIBCALL wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr) double CLIBCALL wcstod(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr) {
return __infer_nondet_double(); return __infer_nondet_double();
} }
float CLIBCALL wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr) float CLIBCALL wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr) {
{
return __infer_nondet_float(); return __infer_nondet_float();
} }
// simplified modeling which returns s1 // simplified modeling which returns s1
wchar_t * CLIBCALL wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr) wchar_t* CLIBCALL wcstok(wchar_t* restrict s1,
{ const wchar_t* restrict s2,
wchar_t** restrict ptr) {
return s1; return s1;
} }
long double CLIBCALL wcstold(const wchar_t * restrict nptr, wchar_t ** restrict endptr) long double CLIBCALL wcstold(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr) {
return __infer_nondet_long_double(); return __infer_nondet_long_double();
} }
long int CLIBCALL wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) long int CLIBCALL wcstol(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr,
int base) {
return __infer_nondet_long_int(); return __infer_nondet_long_int();
} }
long long int CLIBCALL wcstoll(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) long long int CLIBCALL wcstoll(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr,
int base) {
return __infer_nondet_long_long_int(); return __infer_nondet_long_long_int();
} }
unsigned long int CLIBCALL wcstoul(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) unsigned long int CLIBCALL wcstoul(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr,
int base) {
return __infer_nondet_unsigned_long_int(); return __infer_nondet_unsigned_long_int();
} }
unsigned long long int CLIBCALL wcstoull(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) unsigned long long int CLIBCALL wcstoull(const wchar_t* restrict nptr,
{ wchar_t** restrict endptr,
int base) {
return __infer_nondet_long_long_int(); return __infer_nondet_long_long_int();
} }
// modeled using strncmp // modeled using strncmp
size_t CLIBCALL wcsxfrm(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) size_t CLIBCALL wcsxfrm(wchar_t* restrict s1,
{ const wchar_t* restrict s2,
return strncmp((char *) s1, (char *) s2, n); size_t n) {
return strncmp((char*)s1, (char*)s2, n);
} }
// modeled using memchr // modeled using memchr
#ifndef USE_CPP_OVERLOADS #ifndef USE_CPP_OVERLOADS
wchar_t * CLIBCALL wmemchr(const wchar_t *s, wchar_t c, size_t n) wchar_t* CLIBCALL wmemchr(const wchar_t* s, wchar_t c, size_t n)
#else #else
const wchar_t * CLIBCALL wmemchr(const wchar_t *s, wchar_t c, size_t n) const wchar_t* CLIBCALL wmemchr(const wchar_t* s, wchar_t c, size_t n) {
{ return wmemchr((wchar_t*)s, c, n);
return wmemchr((wchar_t*) s, c, n);
} }
wchar_t * CLIBCALL wmemchr(wchar_t *s, wchar_t c, size_t n) wchar_t* CLIBCALL wmemchr(wchar_t* s, wchar_t c, size_t n)
#endif #endif
{ {
return (wchar_t *) memchr((char *) s, c, n); return (wchar_t*)memchr((char*)s, c, n);
} }
// modeled using memcmp // modeled using memcmp
int CLIBCALL wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) int CLIBCALL wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n) {
{ return memcmp((char*)s1, (char*)s2, n);
return memcmp((char *) s1, (char *) s2, n);
} }
// modeled using memcpy // modeled using memcpy
wchar_t * CLIBCALL wmemcpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) wchar_t* CLIBCALL wmemcpy(wchar_t* restrict s1,
{ const wchar_t* restrict s2,
return (wchar_t *) memcpy((char *) s1, (char *) s2, n); size_t n) {
return (wchar_t*)memcpy((char*)s1, (char*)s2, n);
} }
// modeled using memmove // modeled using memmove
wchar_t * CLIBCALL wmemmove(wchar_t *s1, const wchar_t *s2, size_t n) wchar_t* CLIBCALL wmemmove(wchar_t* s1, const wchar_t* s2, size_t n) {
{ return (wchar_t*)memmove((char*)s1, (char*)s2, n);
return (wchar_t *) memmove((char *) s1, (char *) s2, n);
} }
// modeled using memset // modeled using memset
wchar_t * CLIBCALL wmemset(wchar_t *s, wchar_t c, size_t n) wchar_t* CLIBCALL wmemset(wchar_t* s, wchar_t c, size_t n) {
{ return (wchar_t*)memset((char*)s, c, n);
return (wchar_t *) memset((char *) s, c, n);
} }

@ -23,105 +23,50 @@
#define CLIBCALL #define CLIBCALL
#endif #endif
// Microsoft-specific // Microsoft-specific
int CLIBCALL __iswcsymf(wint_t wc) int CLIBCALL __iswcsymf(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
// Microsoft-specific, inline // Microsoft-specific, inline
int CLIBCALL isleadbyte(int wc) int CLIBCALL isleadbyte(int wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswalnum(wint_t wc) int CLIBCALL iswalnum(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswalpha(wint_t wc) int CLIBCALL iswalpha(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswblank(wint_t wc) int CLIBCALL iswblank(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswcntrl(wint_t wc) int CLIBCALL iswcntrl(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswctype(wint_t wc, wctype_t desc) int CLIBCALL iswctype(wint_t wc, wctype_t desc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswdigit(wint_t wc) int CLIBCALL iswdigit(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswgraph(wint_t wc) int CLIBCALL iswgraph(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswlower(wint_t wc) int CLIBCALL iswlower(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswprint(wint_t wc) int CLIBCALL iswprint(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswpunct(wint_t wc) int CLIBCALL iswpunct(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswspace(wint_t wc) int CLIBCALL iswspace(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswupper(wint_t wc) int CLIBCALL iswupper(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
int CLIBCALL iswxdigit(wint_t wc) int CLIBCALL iswxdigit(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
wint_t CLIBCALL towlower(wint_t wc) wint_t CLIBCALL towlower(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
wint_t CLIBCALL towctrans(wint_t wc, wctrans_t desc) wint_t CLIBCALL towctrans(wint_t wc, wctrans_t desc) {
{
return __infer_nondet_int(); return __infer_nondet_int();
} }
wint_t CLIBCALL towupper(wint_t wc) wint_t CLIBCALL towupper(wint_t wc) { return __infer_nondet_int(); }
{
return __infer_nondet_int();
}
wctrans_t CLIBCALL wctrans(const char *property) wctrans_t CLIBCALL wctrans(const char* property) {
{
return (wctrans_t)__infer_nondet_int(); return (wctrans_t)__infer_nondet_int();
} }
wctype_t CLIBCALL wctype(const char *property) wctype_t CLIBCALL wctype(const char* property) {
{
return (wctype_t)__infer_nondet_int(); return (wctype_t)__infer_nondet_int();
} }

@ -15,14 +15,14 @@
#include <stdlib.h> #include <stdlib.h>
// modelled using malloc // modelled using malloc
char *XGetAtomName(void *display, void *atom) { char* XGetAtomName(void* display, void* atom) {
int size; int size;
INFER_EXCLUDE_CONDITION(size <= 0); INFER_EXCLUDE_CONDITION(size <= 0);
return (char*)malloc(size); return (char*)malloc(size);
} }
// modelled as free, requires NONNULL pointer // modelled as free, requires NONNULL pointer
void XFree(void *ptr) { void XFree(void* ptr) {
INFER_EXCLUDE_CONDITION(!ptr); INFER_EXCLUDE_CONDITION(!ptr);
free(ptr); free(ptr);
} }

@ -10,35 +10,32 @@
// models for shared_ptr // models for shared_ptr
extern "C" void __method_set_ignore_attribute(void **self, void *arg); extern "C" void __method_set_ignore_attribute(void** self, void* arg);
// standard constructor // standard constructor
extern "C" void __infer_shared_ptr(void **self, void *arg) { extern "C" void __infer_shared_ptr(void** self, void* arg) {
__method_set_ignore_attribute(self, arg); // auto memory management __method_set_ignore_attribute(self, arg); // auto memory management
*self = arg; *self = arg;
} }
// constructor taking a reference to a shared_ptr // constructor taking a reference to a shared_ptr
extern "C" void __infer_shared_ptr_ref(void **arg1, void **arg2) { extern "C" void __infer_shared_ptr_ref(void** arg1, void** arg2) {
*arg1 = *arg2; *arg1 = *arg2;
} }
// operator= // operator=
extern "C" void** __infer_shared_ptr_eq(void **arg1, void **arg2) { extern "C" void** __infer_shared_ptr_eq(void** arg1, void** arg2) {
*arg1 = *arg2; *arg1 = *arg2;
return arg1; return arg1;
} }
// operator== // operator==
extern "C" int __infer_shared_ptr_eqeq(void **arg1, void **arg2) { extern "C" int __infer_shared_ptr_eqeq(void** arg1, void** arg2) {
return (*arg1 == *arg2); return (*arg1 == *arg2);
} }
// operator-> // operator->
extern "C" void* __infer_shared_ptr_arrow(void **arg) { extern "C" void* __infer_shared_ptr_arrow(void** arg) { return *arg; }
return *arg;
}
// destructor // destructor
extern "C" void __infer_shared_ptr_destructor(void **arg) { extern "C" void __infer_shared_ptr_destructor(void** arg) {}
}

@ -12,7 +12,7 @@
@interface CADisplayLink : NSObject { @interface CADisplayLink : NSObject {
id _target; id _target;
SEL _selector; SEL _selector;
} }
@property(readonly, nonatomic) CFTimeInterval duration; @property(readonly, nonatomic) CFTimeInterval duration;
@ -24,10 +24,9 @@
@property(readonly, nonatomic) CFTimeInterval timestamp; @property(readonly, nonatomic) CFTimeInterval timestamp;
// Returns a new display link. // Returns a new display link.
+ (CADisplayLink *)displayLinkWithTarget:(id)target + (CADisplayLink*)displayLinkWithTarget:(id)target selector:(SEL)sel;
selector:(SEL)sel;
// Release the target // Release the target
- (void) invalidate; - (void)invalidate;
@end @end

@ -13,19 +13,18 @@
// Returns a new display link. // Returns a new display link.
// The model retains strongly the target object. // The model retains strongly the target object.
+ (CADisplayLink *)displayLinkWithTarget:(id)target + (CADisplayLink*)displayLinkWithTarget:(id)target selector:(SEL)sel {
selector:(SEL)sel {
CADisplayLink *c = [CADisplayLink alloc]; CADisplayLink* c = [CADisplayLink alloc];
c->_target = target; c->_target = target;
c->_selector = sel; c->_selector = sel;
return c; return c;
} }
// Release the target // Release the target
- (void) invalidate { - (void)invalidate {
self->_target = nil; self->_target = nil;
} }
@end @end

@ -7,47 +7,49 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h> #import <AddressBook/AddressBook.h>
#import <Foundation/Foundation.h>
CFArrayRef __cf_alloc(CFArrayRef); CFArrayRef __cf_alloc(CFArrayRef);
CFArrayRef __cf_non_null_alloc(CFArrayRef); CFArrayRef __cf_non_null_alloc(CFArrayRef);
CFArrayRef CFArrayCreate ( CFAllocatorRef allocator, CFArrayRef CFArrayCreate(CFAllocatorRef allocator,
const void **values, const void** values,
CFIndex numValues, CFIndex numValues,
const CFArrayCallBacks *callBacks ) { const CFArrayCallBacks* callBacks) {
CFArrayRef c; CFArrayRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFArrayRef CFNetworkCopyProxiesForURL ( CFURLRef url, CFDictionaryRef proxySettings ) { CFArrayRef CFNetworkCopyProxiesForURL(CFURLRef url,
CFDictionaryRef proxySettings) {
CFArrayRef c; CFArrayRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFArrayRef CFStringCreateArrayWithFindResults ( CFAllocatorRef alloc, CFArrayRef CFStringCreateArrayWithFindResults(
CFStringRef theString, CFAllocatorRef alloc,
CFStringRef stringToFind, CFStringRef theString,
CFRange rangeToSearch, CFStringRef stringToFind,
CFStringCompareFlags compareOptions ) { CFRange rangeToSearch,
CFStringCompareFlags compareOptions) {
CFArrayRef c; CFArrayRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFArrayRef CFPreferencesCopyKeyList ( CFStringRef applicationID, CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID,
CFStringRef userName, CFStringRef userName,
CFStringRef hostName ) { CFStringRef hostName) {
CFArrayRef c; CFArrayRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFArrayRef CNCopySupportedInterfaces ( void ) { CFArrayRef CNCopySupportedInterfaces(void) {
CFArrayRef c; CFArrayRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFArrayRef ABAddressBookCopyArrayOfAllPeople ( ABAddressBookRef addressBook ) { CFArrayRef ABAddressBookCopyArrayOfAllPeople(ABAddressBookRef addressBook) {
CFArrayRef c; CFArrayRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -11,11 +11,11 @@
CFBinaryHeapRef __cf_alloc(CFBinaryHeapRef); CFBinaryHeapRef __cf_alloc(CFBinaryHeapRef);
CFBinaryHeapRef CFBinaryHeapCreate(
CFBinaryHeapRef CFBinaryHeapCreate ( CFAllocatorRef allocator, CFAllocatorRef allocator,
CFIndex capacity, CFIndex capacity,
const CFBinaryHeapCallBacks *callBacks, const CFBinaryHeapCallBacks* callBacks,
const CFBinaryHeapCompareContext *compareContext) { const CFBinaryHeapCompareContext* compareContext) {
CFBinaryHeapRef c; CFBinaryHeapRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -12,9 +12,9 @@
CFBitVectorRef __cf_alloc(CFBitVectorRef); CFBitVectorRef __cf_alloc(CFBitVectorRef);
CFBitVectorRef __cf_non_null_alloc(CFBitVectorRef); CFBitVectorRef __cf_non_null_alloc(CFBitVectorRef);
CFBitVectorRef CFBitVectorCreate ( CFAllocatorRef allocator, CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator,
const UInt8 *bytes, const UInt8* bytes,
CFIndex numBits ) { CFIndex numBits) {
CFBitVectorRef c; CFBitVectorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -12,8 +12,7 @@
CFDateRef __cf_alloc(CFDateRef); CFDateRef __cf_alloc(CFDateRef);
CFDateRef __cf_non_null_alloc(CFDateRef); CFDateRef __cf_non_null_alloc(CFDateRef);
CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) {
CFDateRef CFDateCreate ( CFAllocatorRef allocator, CFAbsoluteTime at ) {
CFDateRef c; CFDateRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -7,69 +7,67 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <ImageIO/ImageIO.h>
#import <CoreMedia/CoreMedia.h> #import <CoreMedia/CoreMedia.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <ImageIO/ImageIO.h>
CFDictionaryRef __cf_non_null_alloc(CFDictionaryRef); CFDictionaryRef __cf_non_null_alloc(CFDictionaryRef);
CFDictionaryRef __cf_alloc(CFDictionaryRef); CFDictionaryRef __cf_alloc(CFDictionaryRef);
CFDictionaryRef CGImageSourceCopyPropertiesAtIndex ( CGImageSourceRef isrc, CFDictionaryRef CGImageSourceCopyPropertiesAtIndex(CGImageSourceRef isrc,
size_t index, size_t index,
CFDictionaryRef options ) CFDictionaryRef options) {
{ CFDictionaryRef c;
CFDictionaryRef c; return __cf_non_null_alloc(c);
return __cf_non_null_alloc(c);
} }
CFDictionaryRef CFDictionaryCreate(
CFDictionaryRef CFDictionaryCreate ( CFAllocatorRef allocator, CFAllocatorRef allocator,
const void **keys, const void** keys,
const void **values, const void** values,
CFIndex numValues, CFIndex numValues,
const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryKeyCallBacks* keyCallBacks,
const CFDictionaryValueCallBacks *valueCallBacks ) { const CFDictionaryValueCallBacks* valueCallBacks) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFDictionaryRef CFDictionaryCreateCopy ( CFAllocatorRef allocator, CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator,
CFDictionaryRef theDict ) { CFDictionaryRef theDict) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFDictionaryRef CFNetworkCopySystemProxySettings ( void ) { CFDictionaryRef CFNetworkCopySystemProxySettings(void) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFDictionaryRef CGImageSourceCopyProperties ( CGImageSourceRef isrc, CFDictionaryRef options ) { CFDictionaryRef CGImageSourceCopyProperties(CGImageSourceRef isrc,
CFDictionaryRef c; CFDictionaryRef options) {
return __cf_non_null_alloc(c); CFDictionaryRef c;
return __cf_non_null_alloc(c);
} }
CFDictionaryRef CMCopyDictionaryOfAttachments ( CFAllocatorRef allocator, CFDictionaryRef CMCopyDictionaryOfAttachments(CFAllocatorRef allocator,
CMAttachmentBearerRef target, CMAttachmentBearerRef target,
CMAttachmentMode attachmentMode ) { CMAttachmentMode attachmentMode) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFDictionaryRef CFHTTPMessageCopyAllHeaderFields ( CFHTTPMessageRef message ) { CFDictionaryRef CFHTTPMessageCopyAllHeaderFields(CFHTTPMessageRef message) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFDictionaryRef CNCopyCurrentNetworkInfo ( CFStringRef interfaceName ) { CFDictionaryRef CNCopyCurrentNetworkInfo(CFStringRef interfaceName) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFDictionaryRef CMTimeCopyAsDictionary (CMTime time, CFDictionaryRef CMTimeCopyAsDictionary(CMTime time, CFAllocatorRef allocator) {
CFAllocatorRef allocator ) {
CFDictionaryRef c; CFDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -12,13 +12,12 @@
CFErrorRef __cf_alloc(CFErrorRef); CFErrorRef __cf_alloc(CFErrorRef);
CFErrorRef __cf_non_null_alloc(CFErrorRef); CFErrorRef __cf_non_null_alloc(CFErrorRef);
CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) {
CFErrorRef CFReadStreamCopyError ( CFReadStreamRef stream ) {
CFErrorRef c; CFErrorRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFErrorRef CFWriteStreamCopyError ( CFWriteStreamRef stream ) { CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) {
CFErrorRef c; CFErrorRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -11,31 +11,30 @@
CFHTTPMessageRef __cf_alloc(CFHTTPMessageRef); CFHTTPMessageRef __cf_alloc(CFHTTPMessageRef);
CFHTTPMessageRef CFHTTPMessageCreateCopy(CFAllocatorRef alloc,
CFHTTPMessageRef CFHTTPMessageCreateCopy ( CFAllocatorRef alloc, CFHTTPMessageRef message) {
CFHTTPMessageRef message ) { CFHTTPMessageRef c;
CFHTTPMessageRef c; return __cf_alloc(c);
return __cf_alloc(c);
} }
CFHTTPMessageRef CFHTTPMessageCreateEmpty ( CFAllocatorRef alloc, CFHTTPMessageRef CFHTTPMessageCreateEmpty(CFAllocatorRef alloc,
Boolean isRequest ) { Boolean isRequest) {
CFHTTPMessageRef c; CFHTTPMessageRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFHTTPMessageRef CFHTTPMessageCreateRequest ( CFAllocatorRef alloc, CFHTTPMessageRef CFHTTPMessageCreateRequest(CFAllocatorRef alloc,
CFStringRef requestMethod, CFStringRef requestMethod,
CFURLRef url, CFURLRef url,
CFStringRef httpVersion ) { CFStringRef httpVersion) {
CFHTTPMessageRef c; CFHTTPMessageRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFHTTPMessageRef CFHTTPMessageCreateResponse ( CFAllocatorRef alloc, CFHTTPMessageRef CFHTTPMessageCreateResponse(CFAllocatorRef alloc,
CFIndex statusCode, CFIndex statusCode,
CFStringRef statusDescription, CFStringRef statusDescription,
CFStringRef httpVersion ) { CFStringRef httpVersion) {
CFHTTPMessageRef c; CFHTTPMessageRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -17,8 +17,8 @@ CFLocaleRef CFLocaleCopyCurrent(void) {
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFLocaleRef CFLocaleCreate ( CFAllocatorRef allocator, CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator,
CFStringRef localeIdentifier ) { CFStringRef localeIdentifier) {
CFLocaleRef c; CFLocaleRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -12,9 +12,9 @@
CFMutableArrayRef __cf_alloc(CFMutableArrayRef); CFMutableArrayRef __cf_alloc(CFMutableArrayRef);
CFMutableArrayRef __cf_non_null_alloc(CFMutableArrayRef); CFMutableArrayRef __cf_non_null_alloc(CFMutableArrayRef);
CFMutableArrayRef CFArrayCreateMutable ( CFAllocatorRef allocator, CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator,
CFIndex capacity, CFIndex capacity,
const CFArrayCallBacks *callBacks ) { const CFArrayCallBacks* callBacks) {
CFMutableArrayRef c; CFMutableArrayRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -11,8 +11,8 @@
CFMutableAttributedStringRef __cf_non_null_alloc(CFMutableAttributedStringRef); CFMutableAttributedStringRef __cf_non_null_alloc(CFMutableAttributedStringRef);
CFMutableAttributedStringRef CFAttributedStringCreateMutable (CFAllocatorRef alloc, CFMutableAttributedStringRef CFAttributedStringCreateMutable(
CFIndex maxLength ) { CFAllocatorRef alloc, CFIndex maxLength) {
CFMutableAttributedStringRef c; CFMutableAttributedStringRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -7,26 +7,26 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <ImageIO/ImageIO.h>
#import <CoreMedia/CoreMedia.h> #import <CoreMedia/CoreMedia.h>
#import <ImageIO/ImageIO.h>
CFMutableDictionaryRef __cf_non_null_alloc(CFMutableDictionaryRef); CFMutableDictionaryRef __cf_non_null_alloc(CFMutableDictionaryRef);
CFMutableDictionaryRef __cf_alloc(CFMutableDictionaryRef); CFMutableDictionaryRef __cf_alloc(CFMutableDictionaryRef);
CFMutableDictionaryRef CFDictionaryCreateMutable ( CFAllocatorRef allocator, CFMutableDictionaryRef CFDictionaryCreateMutable(
CFIndex capacity, CFAllocatorRef allocator,
const CFDictionaryKeyCallBacks *keyCallBacks, CFIndex capacity,
const CFDictionaryValueCallBacks *valueCallBacks ) { const CFDictionaryKeyCallBacks* keyCallBacks,
const CFDictionaryValueCallBacks* valueCallBacks) {
CFMutableDictionaryRef c; CFMutableDictionaryRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFMutableDictionaryRef CFDictionaryCreateMutableCopy ( CFAllocatorRef allocator, CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator,
CFIndex capacity, CFIndex capacity,
CFDictionaryRef theDict ) { CFDictionaryRef theDict) {
CFMutableDictionaryRef c; CFMutableDictionaryRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -7,22 +7,21 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
CFMutableSetRef __cf_alloc(CFMutableSetRef); CFMutableSetRef __cf_alloc(CFMutableSetRef);
CFMutableSetRef __cf_non_null_alloc(CFMutableSetRef); CFMutableSetRef __cf_non_null_alloc(CFMutableSetRef);
CFMutableSetRef CFSetCreateMutable (CFAllocatorRef allocator, CFMutableSetRef CFSetCreateMutable(CFAllocatorRef allocator,
CFIndex capacity, CFIndex capacity,
const CFSetCallBacks *callBacks) { const CFSetCallBacks* callBacks) {
CFMutableSetRef c; CFMutableSetRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CFMutableSetRef CFSetCreateMutableCopy ( CFAllocatorRef allocator, CFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator,
CFIndex capacity, CFIndex capacity,
CFSetRef theSet ) { CFSetRef theSet) {
CFMutableSetRef c; CFMutableSetRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -11,10 +11,9 @@
CFNumberRef __cf_alloc(CFNumberRef); CFNumberRef __cf_alloc(CFNumberRef);
CFNumberRef CFNumberCreate(CFAllocatorRef allocator,
CFNumberRef CFNumberCreate ( CFAllocatorRef allocator, CFNumberType theType,
CFNumberType theType, const void* valuePtr) {
const void *valuePtr ) { CFNumberRef c;
CFNumberRef c; return __cf_alloc(c);
return __cf_alloc(c);
} }

@ -12,16 +12,16 @@
CFRunLoopSourceRef __cf_alloc(CFRunLoopSourceRef); CFRunLoopSourceRef __cf_alloc(CFRunLoopSourceRef);
CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef); CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef);
CFRunLoopSourceRef CFRunLoopSourceCreate ( CFAllocatorRef allocator, CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator,
CFIndex order, CFIndex order,
CFRunLoopSourceContext *context ) { CFRunLoopSourceContext* context) {
CFRunLoopSourceRef c; CFRunLoopSourceRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFRunLoopSourceRef CFSocketCreateRunLoopSource ( CFAllocatorRef allocator, CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator,
CFSocketRef s, CFSocketRef s,
CFIndex order ) { CFIndex order) {
CFRunLoopSourceRef c; CFRunLoopSourceRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -12,24 +12,23 @@
CFRunLoopObserverRef __cf_alloc(CFRunLoopObserverRef); CFRunLoopObserverRef __cf_alloc(CFRunLoopObserverRef);
CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef); CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef);
CFRunLoopObserverRef CFRunLoopObserverCreate ( CFAllocatorRef allocator, CFRunLoopObserverRef CFRunLoopObserverCreate(
CFOptionFlags activities, CFAllocatorRef allocator,
Boolean repeats, CFOptionFlags activities,
CFIndex order, Boolean repeats,
CFRunLoopObserverCallBack callout, CFIndex order,
CFRunLoopObserverContext *context) { CFRunLoopObserverCallBack callout,
CFRunLoopObserverRef c; CFRunLoopObserverContext* context) {
return __cf_non_null_alloc(c); CFRunLoopObserverRef c;
return __cf_non_null_alloc(c);
} }
CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler(
CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler ( CFAllocatorRef allocator, CFAllocatorRef allocator,
CFOptionFlags activities, CFOptionFlags activities,
Boolean repeats, Boolean repeats,
CFIndex order, CFIndex order,
void (^block)( void (^block)(CFRunLoopObserverRef observer, CFRunLoopActivity activity)) {
CFRunLoopObserverRef observer, CFRunLoopObserverRef c;
CFRunLoopActivity activity) ) { return __cf_non_null_alloc(c);
CFRunLoopObserverRef c;
return __cf_non_null_alloc(c);
} }

@ -11,13 +11,13 @@
CFSocketRef __cf_alloc(CFSocketRef); CFSocketRef __cf_alloc(CFSocketRef);
CFSocketRef CFSocketCreate ( CFAllocatorRef allocator, CFSocketRef CFSocketCreate(CFAllocatorRef allocator,
SInt32 protocolFamily, SInt32 protocolFamily,
SInt32 socketType, SInt32 socketType,
SInt32 protocol, SInt32 protocol,
CFOptionFlags callBackTypes, CFOptionFlags callBackTypes,
CFSocketCallBack callout, CFSocketCallBack callout,
const CFSocketContext *context ) { const CFSocketContext* context) {
CFSocketRef c; CFSocketRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -14,20 +14,19 @@ CFStringRef __cf_alloc(CFStringRef);
void __get_array_size(const UInt8); void __get_array_size(const UInt8);
CFStringRef CFStringCreateWithBytesNoCopy ( CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc,
CFAllocatorRef alloc, const UInt8* bytes,
const UInt8 *bytes, CFIndex numBytes,
CFIndex numBytes, CFStringEncoding encoding,
CFStringEncoding encoding, Boolean isExternalRepresentation,
Boolean isExternalRepresentation, CFAllocatorRef contentsDeallocator) {
CFAllocatorRef contentsDeallocator ) { CFStringRef c;
CFStringRef c; CFStringRef s = __cf_alloc(c);
CFStringRef s = __cf_alloc(c); if (s) {
if (s) { if (bytes) {
if (bytes) { __get_array_size(bytes);
__get_array_size(bytes); free(bytes);
free(bytes); }
} }
} return s;
return s;
} }

@ -12,11 +12,11 @@
CFStringTokenizerRef __cf_alloc(CFStringTokenizerRef); CFStringTokenizerRef __cf_alloc(CFStringTokenizerRef);
CFStringTokenizerRef __cf_non_null_alloc(CFStringTokenizerRef); CFStringTokenizerRef __cf_non_null_alloc(CFStringTokenizerRef);
CFStringTokenizerRef CFStringTokenizerCreate ( CFAllocatorRef alloc, CFStringTokenizerRef CFStringTokenizerCreate(CFAllocatorRef alloc,
CFStringRef string, CFStringRef string,
CFRange range, CFRange range,
CFOptionFlags options, CFOptionFlags options,
CFLocaleRef locale ) { CFLocaleRef locale) {
CFStringTokenizerRef c; CFStringTokenizerRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -9,6 +9,4 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
CFTypeRef CFMakeCollectable ( CFTypeRef cf ) { CFTypeRef CFMakeCollectable(CFTypeRef cf) { return cf; }
return cf;
}

@ -12,13 +12,13 @@
CFUUIDRef __cf_alloc(CFUUIDRef); CFUUIDRef __cf_alloc(CFUUIDRef);
CFUUIDRef __cf_non_null_alloc(CFUUIDRef); CFUUIDRef __cf_non_null_alloc(CFUUIDRef);
CFUUIDRef CFUUIDCreate ( CFAllocatorRef alloc ){ CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) {
CFUUIDRef c; CFUUIDRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CFUUIDRef CFUUIDCreateFromUUIDBytes ( CFAllocatorRef alloc, CFUUIDBytes bytes ) { CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes) {
CFUUIDRef c; CFUUIDRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -11,9 +11,9 @@
CTFontRef __cf_alloc(CTFontRef); CTFontRef __cf_alloc(CTFontRef);
CTFontRef CTFontCreateWithName ( CFStringRef name, CTFontRef CTFontCreateWithName(CFStringRef name,
CGFloat size, CGFloat size,
const CGAffineTransform *matrix ) { const CGAffineTransform* matrix) {
CTFontRef c; CTFontRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -11,7 +11,8 @@
CTFramesetterRef __cf_alloc(CTFramesetterRef); CTFramesetterRef __cf_alloc(CTFramesetterRef);
CTFramesetterRef CTFramesetterCreateWithAttributedString ( CFAttributedStringRef string ) { CTFramesetterRef CTFramesetterCreateWithAttributedString(
CTFramesetterRef c; CFAttributedStringRef string) {
return __cf_alloc(c); CTFramesetterRef c;
return __cf_alloc(c);
} }

@ -7,15 +7,14 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/Foundation.h>
#import <CoreText/CoreText.h> #import <CoreText/CoreText.h>
#import <Foundation/Foundation.h>
CTParagraphStyleRef __cf_alloc(CTParagraphStyleRef); CTParagraphStyleRef __cf_alloc(CTParagraphStyleRef);
CTParagraphStyleRef __cf_non_null_alloc(CTParagraphStyleRef); CTParagraphStyleRef __cf_non_null_alloc(CTParagraphStyleRef);
CTParagraphStyleRef CTParagraphStyleCreate(
CTParagraphStyleRef CTParagraphStyleCreate ( const CTParagraphStyleSetting *settings, const CTParagraphStyleSetting* settings, size_t settingCount) {
size_t settingCount ) { CTParagraphStyleRef c;
CTParagraphStyleRef c; return __cf_alloc(c);
return __cf_alloc(c);
} }

@ -7,20 +7,19 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/Foundation.h>
#import "SystemConfiguration/SCNetworkReachability.h" #import "SystemConfiguration/SCNetworkReachability.h"
#import <Foundation/Foundation.h>
SCNetworkReachabilityRef __cf_non_null_alloc(SCNetworkReachabilityRef); SCNetworkReachabilityRef __cf_non_null_alloc(SCNetworkReachabilityRef);
SCNetworkReachabilityRef SCNetworkReachabilityCreateWithName ( SCNetworkReachabilityRef SCNetworkReachabilityCreateWithName(
CFAllocatorRef allocator, CFAllocatorRef allocator, const char* nodename) {
const char *nodename ) { SCNetworkReachabilityRef c;
SCNetworkReachabilityRef c; return __cf_non_null_alloc(c);
return __cf_non_null_alloc(c);
} }
SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress ( CFAllocatorRef allocator, SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress(
const struct sockaddr *address ) { CFAllocatorRef allocator, const struct sockaddr* address) {
SCNetworkReachabilityRef c; SCNetworkReachabilityRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -13,9 +13,8 @@ SecCertificateRef __cf_alloc(SecCertificateRef);
SecCertificateRef __cf_non_null_alloc(SecCertificateRef); SecCertificateRef __cf_non_null_alloc(SecCertificateRef);
SecCertificateRef SecCertificateCreateWithData(CFAllocatorRef allocator,
SecCertificateRef SecCertificateCreateWithData ( CFAllocatorRef allocator, CFDataRef data) {
CFDataRef data ) { SecCertificateRef c;
SecCertificateRef c; return __cf_alloc(c);
return __cf_alloc(c);
} }

@ -14,18 +14,17 @@ SecKeyRef __cf_alloc(SecKeyRef);
SecPolicyRef __cf_non_null_alloc(SecPolicyRef); SecPolicyRef __cf_non_null_alloc(SecPolicyRef);
SecKeyRef SecTrustCopyPublicKey ( SecTrustRef trust ){ SecKeyRef SecTrustCopyPublicKey(SecTrustRef trust) {
SecKeyRef c; SecKeyRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
SecPolicyRef SecPolicyCreateSSL(Boolean server, CFStringRef hostname) {
SecPolicyRef SecPolicyCreateSSL ( Boolean server, CFStringRef hostname ) { SecPolicyRef c;
SecPolicyRef c; return __cf_non_null_alloc(c);
return __cf_non_null_alloc(c);
} }
SecPolicyRef SecPolicyCreateBasicX509 ( void ) { SecPolicyRef SecPolicyCreateBasicX509(void) {
SecPolicyRef c; SecPolicyRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -13,33 +13,34 @@ CGColorRef __cf_non_null_alloc(CGColorRef);
void __objc_release_cf(CGColorRef); void __objc_release_cf(CGColorRef);
void CGColorRelease (CGColorRef color) { void CGColorRelease(CGColorRef color) {
if (color) __objc_release_cf(color); if (color)
__objc_release_cf(color);
} }
CGColorRef CGColorCreate(CGColorSpaceRef space, const CGFloat components[]) { CGColorRef CGColorCreate(CGColorSpaceRef space, const CGFloat components[]) {
CGColorRef c; CGColorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGColorRef CGColorCreateCopyWithAlpha ( CGColorRef color, CGFloat alpha ) { CGColorRef CGColorCreateCopyWithAlpha(CGColorRef color, CGFloat alpha) {
CGColorRef c; CGColorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
//FB own code // FB own code
CGColorRef FBColorCreateWithGray(CGFloat gray, CGFloat a) { CGColorRef FBColorCreateWithGray(CGFloat gray, CGFloat a) {
CGColorRef c; CGColorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGColorRef FBColorCreateWithRGBA(uint8_t r, uint8_t g, uint8_t b, CGFloat a) { CGColorRef FBColorCreateWithRGBA(uint8_t r, uint8_t g, uint8_t b, CGFloat a) {
CGColorRef c; CGColorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGColorRef FBColorCreateWithRGB(uint8_t r, uint8_t g, uint8_t b) { CGColorRef FBColorCreateWithRGB(uint8_t r, uint8_t g, uint8_t b) {
CGColorRef c; CGColorRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -11,18 +11,19 @@
void __objc_release_cf(CGColorSpaceRef); void __objc_release_cf(CGColorSpaceRef);
void CGColorSpaceRelease ( CGColorSpaceRef space ) { void CGColorSpaceRelease(CGColorSpaceRef space) {
if (space) __objc_release_cf(space); if (space)
__objc_release_cf(space);
} }
CGColorSpaceRef __cf_alloc(CGColorSpaceRef); CGColorSpaceRef __cf_alloc(CGColorSpaceRef);
CGColorSpaceRef CGColorSpaceCreateDeviceRGB ( void ) { CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void) {
CGColorSpaceRef c; CGColorSpaceRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CGColorSpaceRef CGColorSpaceCreateDeviceGray ( void ) { CGColorSpaceRef CGColorSpaceCreateDeviceGray(void) {
CGColorSpaceRef c; CGColorSpaceRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -13,19 +13,20 @@
void __objc_release_cf(CGContextRef); void __objc_release_cf(CGContextRef);
void CGContextRelease ( CGContextRef c ){ void CGContextRelease(CGContextRef c) {
if (c) __objc_release_cf(c); if (c)
__objc_release_cf(c);
} }
CGContextRef __cf_alloc(CGContextRef); CGContextRef __cf_alloc(CGContextRef);
CGContextRef CGBitmapContextCreate ( void *data, CGContextRef CGBitmapContextCreate(void* data,
size_t width, size_t width,
size_t height, size_t height,
size_t bitsPerComponent, size_t bitsPerComponent,
size_t bytesPerRow, size_t bytesPerRow,
CGColorSpaceRef space, CGColorSpaceRef space,
CGBitmapInfo bitmapInfo ) { CGBitmapInfo bitmapInfo) {
CGContextRef c; CGContextRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGDataConsumerRef); void __objc_release_cf(CGDataConsumerRef);
void CGDataConsumerRelease ( CGDataConsumerRef consumer ) { void CGDataConsumerRelease(CGDataConsumerRef consumer) {
if (consumer) __objc_release_cf(consumer); if (consumer)
__objc_release_cf(consumer);
} }

@ -11,41 +11,42 @@
void __objc_release_cf(CGDataProviderRef); void __objc_release_cf(CGDataProviderRef);
void CGDataProviderRelease ( CGDataProviderRef provider ){ void CGDataProviderRelease(CGDataProviderRef provider) {
if (provider) __objc_release_cf(provider); if (provider)
__objc_release_cf(provider);
} }
CGDataProviderRef __cf_alloc(CGDataProviderRef); CGDataProviderRef __cf_alloc(CGDataProviderRef);
CGDataProviderRef __cf_non_null_alloc(CGDataProviderRef); CGDataProviderRef __cf_non_null_alloc(CGDataProviderRef);
CGDataProviderRef CGDataProviderCreateWithCFData ( CFDataRef data ) { CGDataProviderRef CGDataProviderCreateWithCFData(CFDataRef data) {
CGDataProviderRef c; CGDataProviderRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGDataProviderRef CGDataProviderCreateWithData ( void *info, CGDataProviderRef CGDataProviderCreateWithData(
const void *data, size_t size, void* info,
CGDataProviderReleaseDataCallback releaseData ) { const void* data,
CGDataProviderRef c; size_t size,
return __cf_non_null_alloc(c); CGDataProviderReleaseDataCallback releaseData) {
CGDataProviderRef c;
return __cf_non_null_alloc(c);
} }
CGDataProviderRef CGDataProviderCreateWithURL ( CFURLRef url ) { CGDataProviderRef CGDataProviderCreateWithURL(CFURLRef url) {
CGDataProviderRef c; CGDataProviderRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CGDataProviderRef CGDataProviderCreateDirect(
CGDataProviderRef CGDataProviderCreateDirect ( void *info, void* info, off_t size, const CGDataProviderDirectCallbacks* callbacks) {
off_t size, CGDataProviderRef c;
const CGDataProviderDirectCallbacks *callbacks) { return __cf_non_null_alloc(c);
CGDataProviderRef c;
return __cf_non_null_alloc(c);
} }
CGDataProviderRef CGDataProviderCreateSequential ( void *info, CGDataProviderRef CGDataProviderCreateSequential(
const CGDataProviderSequentialCallbacks *callbacks ) { void* info, const CGDataProviderSequentialCallbacks* callbacks) {
CGDataProviderRef c; CGDataProviderRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -13,11 +13,12 @@ void __objc_release_cf(CGFontRef);
CGFontRef __cf_alloc(CGFontRef); CGFontRef __cf_alloc(CGFontRef);
void CGFontRelease ( CGFontRef font ) { void CGFontRelease(CGFontRef font) {
if (font) __objc_release_cf(font); if (font)
__objc_release_cf(font);
} }
CGFontRef CGFontCreateWithDataProvider ( CGDataProviderRef provider ) { CGFontRef CGFontCreateWithDataProvider(CGDataProviderRef provider) {
CGFontRef c; CGFontRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGFunctionRef); void __objc_release_cf(CGFunctionRef);
void CGFunctionRelease ( CGFunctionRef function ) { void CGFunctionRelease(CGFunctionRef function) {
if (function) __objc_release_cf(function); if (function)
__objc_release_cf(function);
} }

@ -11,23 +11,24 @@
void __objc_release_cf(CGGradientRef); void __objc_release_cf(CGGradientRef);
void CGGradientRelease ( CGGradientRef gradient ) { void CGGradientRelease(CGGradientRef gradient) {
if (gradient) __objc_release_cf(gradient); if (gradient)
__objc_release_cf(gradient);
} }
CGGradientRef __cf_non_null_alloc(CGGradientRef); CGGradientRef __cf_non_null_alloc(CGGradientRef);
CGGradientRef CGGradientCreateWithColors ( CGColorSpaceRef space, CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
CFArrayRef colors, CFArrayRef colors,
const CGFloat locations[]) { const CGFloat locations[]) {
CGGradientRef c; CGGradientRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGGradientRef CGGradientCreateWithColorComponents ( CGColorSpaceRef space, CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef space,
const CGFloat components[], const CGFloat components[],
const CGFloat locations[], const CGFloat locations[],
size_t count ) { size_t count) {
CGGradientRef c; CGGradientRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -14,72 +14,72 @@ CGImageRef __cf_non_null_alloc(CGImageRef);
CGImageRef __cf_alloc(CGImageRef); CGImageRef __cf_alloc(CGImageRef);
void __objc_release_cf(CGImageRef); void __objc_release_cf(CGImageRef);
CGImageRef CGImageSourceCreateImageAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options ) CGImageRef CGImageSourceCreateImageAtIndex(CGImageSourceRef isrc,
{ size_t index,
CGImageRef c; CFDictionaryRef options) {
return __cf_non_null_alloc(c); CGImageRef c;
return __cf_non_null_alloc(c);
} }
CGImageRef CGImageSourceCreateThumbnailAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options ) CGImageRef CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef isrc,
{ size_t index,
CGImageRef c; CFDictionaryRef options) {
return __cf_non_null_alloc(c); CGImageRef c;
return __cf_non_null_alloc(c);
} }
void CGImageRelease(CGImageRef image) {
void CGImageRelease ( CGImageRef image ) if (image)
{ __objc_release_cf(image);
if (image) __objc_release_cf(image);
} }
CGImageRef CGBitmapContextCreateImage ( CGContextRef context ) CGImageRef CGBitmapContextCreateImage(CGContextRef context) {
{ CGImageRef c;
CGImageRef c; return __cf_alloc(c);
return __cf_alloc(c);
} }
CGImageRef CGImageCreateCopy ( CGImageRef image ) { CGImageRef CGImageCreateCopy(CGImageRef image) {
CGImageRef c; CGImageRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageRef CGImageCreateWithImageInRect ( CGImageRef image, CGRect rect ) { CGImageRef CGImageCreateWithImageInRect(CGImageRef image, CGRect rect) {
CGImageRef c; CGImageRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CGImageRef CGImageCreateWithJPEGDataProvider ( CGDataProviderRef source, CGImageRef CGImageCreateWithJPEGDataProvider(CGDataProviderRef source,
const CGFloat decode[], const CGFloat decode[],
bool shouldInterpolate, bool shouldInterpolate,
CGColorRenderingIntent intent) { CGColorRenderingIntent intent) {
CGImageRef c; CGImageRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageRef CGImageCreateWithPNGDataProvider ( CGDataProviderRef source, CGImageRef CGImageCreateWithPNGDataProvider(CGDataProviderRef source,
const CGFloat decode[], const CGFloat decode[],
bool shouldInterpolate, bool shouldInterpolate,
CGColorRenderingIntent intent ) { CGColorRenderingIntent intent) {
CGImageRef c; CGImageRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageRef CGImageCreate ( size_t width, CGImageRef CGImageCreate(size_t width,
size_t height, size_t height,
size_t bitsPerComponent, size_t bitsPerComponent,
size_t bitsPerPixel, size_t bitsPerPixel,
size_t bytesPerRow, size_t bytesPerRow,
CGColorSpaceRef space, CGColorSpaceRef space,
CGBitmapInfo bitmapInfo, CGBitmapInfo bitmapInfo,
CGDataProviderRef provider, CGDataProviderRef provider,
const CGFloat decode[], const CGFloat decode[],
bool shouldInterpolate, bool shouldInterpolate,
CGColorRenderingIntent intent) { CGColorRenderingIntent intent) {
CGImageRef c; CGImageRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageRef CGImageCreateWithMask ( CGImageRef image, CGImageRef mask ) { CGImageRef CGImageCreateWithMask(CGImageRef image, CGImageRef mask) {
CGImageRef c; CGImageRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -13,18 +13,19 @@
CGImageDestinationRef __cf_non_null_alloc(CGImageDestinationRef); CGImageDestinationRef __cf_non_null_alloc(CGImageDestinationRef);
CGImageDestinationRef __cf_alloc(CGImageDestinationRef); CGImageDestinationRef __cf_alloc(CGImageDestinationRef);
CGImageDestinationRef CGImageDestinationCreateWithURL (CFURLRef url, CGImageDestinationRef CGImageDestinationCreateWithURL(CFURLRef url,
CFStringRef type, CFStringRef type,
size_t count, size_t count,
CFDictionaryRef options) { CFDictionaryRef options) {
CGImageDestinationRef c; CGImageDestinationRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageDestinationRef CGImageDestinationCreateWithData ( CFMutableDataRef data, CGImageDestinationRef CGImageDestinationCreateWithData(
CFStringRef type, CFMutableDataRef data,
size_t count, CFStringRef type,
CFDictionaryRef options) { size_t count,
CGImageDestinationRef c; CFDictionaryRef options) {
return __cf_non_null_alloc(c); CGImageDestinationRef c;
return __cf_non_null_alloc(c);
} }

@ -14,31 +14,30 @@ CGImageSourceRef __cf_non_null_alloc(CGImageSourceRef);
CGImageSourceRef __cf_alloc(CGImageSourceRef); CGImageSourceRef __cf_alloc(CGImageSourceRef);
void __objc_release_cf(CGImageSourceRef); void __objc_release_cf(CGImageSourceRef);
CGImageSourceRef CGImageSourceCreateWithData ( CFDataRef data, CFDictionaryRef options ) CGImageSourceRef CGImageSourceCreateWithData(CFDataRef data,
{ CFDictionaryRef options) {
CGImageSourceRef c; CGImageSourceRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageSourceRef CGImageSourceCreateWithDataProvider ( CGDataProviderRef provider, CFDictionaryRef options ) CGImageSourceRef CGImageSourceCreateWithDataProvider(CGDataProviderRef provider,
{ CFDictionaryRef options) {
CGImageSourceRef c; CGImageSourceRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGImageSourceRef CGImageSourceCreateWithURL ( CFURLRef url, CFDictionaryRef options ) CGImageSourceRef CGImageSourceCreateWithURL(CFURLRef url,
{ CFDictionaryRef options) {
CGImageSourceRef c; CGImageSourceRef c;
return __cf_alloc(c); return __cf_alloc(c);
} }
CGImageSourceRef CGImageSourceCreateIncremental ( CFDictionaryRef options ) CGImageSourceRef CGImageSourceCreateIncremental(CFDictionaryRef options) {
{ CGImageSourceRef c;
CGImageSourceRef c; return __cf_non_null_alloc(c);
return __cf_non_null_alloc(c);
} }
void CGImageSourceRelease ( CGImageSourceRef image ) void CGImageSourceRelease(CGImageSourceRef image) {
{ if (image)
if (image) __objc_release_cf(image); __objc_release_cf(image);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGLayerRef); void __objc_release_cf(CGLayerRef);
void CGLayerRelease ( CGLayerRef layer ){ void CGLayerRelease(CGLayerRef layer) {
if (layer) __objc_release_cf(layer); if (layer)
__objc_release_cf(layer);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPDFContentStreamRef); void __objc_release_cf(CGPDFContentStreamRef);
void CGPDFContentStreamRelease ( CGPDFContentStreamRef cs ) { void CGPDFContentStreamRelease(CGPDFContentStreamRef cs) {
if (cs) __objc_release_cf(cs); if (cs)
__objc_release_cf(cs);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPDFDocumentRef); void __objc_release_cf(CGPDFDocumentRef);
void CGPDFDocumentRelease ( CGPDFDocumentRef document ) { void CGPDFDocumentRelease(CGPDFDocumentRef document) {
if (document) __objc_release_cf(document); if (document)
__objc_release_cf(document);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPDFOperatorTableRef); void __objc_release_cf(CGPDFOperatorTableRef);
void CGPDFOperatorTableRelease ( CGPDFOperatorTableRef table ) { void CGPDFOperatorTableRelease(CGPDFOperatorTableRef table) {
if (table) __objc_release_cf(table); if (table)
__objc_release_cf(table);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPDFPageRef); void __objc_release_cf(CGPDFPageRef);
void CGPDFPageRelease ( CGPDFPageRef page ) { void CGPDFPageRelease(CGPDFPageRef page) {
if (page) __objc_release_cf(page); if (page)
__objc_release_cf(page);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPDFScannerRef); void __objc_release_cf(CGPDFScannerRef);
void CGPDFScannerRelease ( CGPDFScannerRef scanner ) { void CGPDFScannerRelease(CGPDFScannerRef scanner) {
if (scanner) __objc_release_cf(scanner); if (scanner)
__objc_release_cf(scanner);
} }

@ -13,42 +13,43 @@
CGPathRef __cf_non_null_alloc(CGPathRef); CGPathRef __cf_non_null_alloc(CGPathRef);
void __objc_release_cf(CGPathRef); void __objc_release_cf(CGPathRef);
CGMutablePathRef CGPathCreateMutable () { CGMutablePathRef CGPathCreateMutable() {
CGMutablePathRef c; CGMutablePathRef c;
return (CGMutablePathRef) __cf_non_null_alloc(c); return (CGMutablePathRef)__cf_non_null_alloc(c);
} }
CGPathRef CGPathCreateWithRect ( CGRect rect, const CGAffineTransform *transform ) { CGPathRef CGPathCreateWithRect(CGRect rect,
CGPathRef c; const CGAffineTransform* transform) {
return __cf_non_null_alloc(c); CGPathRef c;
return __cf_non_null_alloc(c);
} }
void CGPathRelease ( CGPathRef path ) { void CGPathRelease(CGPathRef path) {
if (path) __objc_release_cf(path); if (path)
__objc_release_cf(path);
} }
CGPathRef CGPathCreateWithEllipseInRect(CGRect rect,
CGPathRef CGPathCreateWithEllipseInRect ( CGRect rect, const CGAffineTransform* transform) {
const CGAffineTransform *transform ){ CGPathRef c;
CGPathRef c; return __cf_non_null_alloc(c);
return __cf_non_null_alloc(c);
} }
CGPathRef CGPathCreateCopy ( CGPathRef path ) { CGPathRef CGPathCreateCopy(CGPathRef path) {
CGPathRef c; CGPathRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGPathRef CGPathCreateCopyByTransformingPath ( CGPathRef path, CGPathRef CGPathCreateCopyByTransformingPath(
const CGAffineTransform *transform ) { CGPathRef path, const CGAffineTransform* transform) {
CGPathRef c; CGPathRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }
CGPathRef CGPathCreateWithRoundedRect ( CGRect rect, CGPathRef CGPathCreateWithRoundedRect(CGRect rect,
CGFloat cornerWidth, CGFloat cornerWidth,
CGFloat cornerHeight, CGFloat cornerHeight,
const CGAffineTransform *transform) { const CGAffineTransform* transform) {
CGPathRef c; CGPathRef c;
return __cf_non_null_alloc(c); return __cf_non_null_alloc(c);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGPatternRef); void __objc_release_cf(CGPatternRef);
void CGPatternRelease ( CGPatternRef pattern ) { void CGPatternRelease(CGPatternRef pattern) {
if (pattern) __objc_release_cf(pattern); if (pattern)
__objc_release_cf(pattern);
} }

@ -11,6 +11,7 @@
void __objc_release_cf(CGShadingRef); void __objc_release_cf(CGShadingRef);
void CGShadingRelease ( CGShadingRef shading ) { void CGShadingRelease(CGShadingRef shading) {
if (shading) __objc_release_cf(shading); if (shading)
__objc_release_cf(shading);
} }

@ -12,7 +12,7 @@
@implementation NSArray @implementation NSArray
+ (instancetype)array { + (instancetype)array {
return [NSArray alloc]; return [NSArray alloc];
} }
@end @end

@ -7,18 +7,18 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#pragma clang diagnostic ignored "-Wprotocol" #pragma clang diagnostic ignored "-Wprotocol"
#pragma clang diagnostic ignored "-Wincomplete-implementation" #pragma clang diagnostic ignored "-Wincomplete-implementation"
#pragma clang diagnostic ignored "-Wimplicit-function-declaration" #pragma clang diagnostic ignored "-Wimplicit-function-declaration"
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
@implementation NSAutoreleasePool @implementation NSAutoreleasePool
- (id)init { - (id)init {
return (id)[self autorelease]; return (id)[self autorelease];
} }
@end @end

@ -14,30 +14,34 @@ NSData* __objc_alloc(NSData*);
@interface NSData : NSObject @interface NSData : NSObject
@property (nonatomic, readonly) const void *bytes; @property(nonatomic, readonly) const void* bytes;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; + (instancetype)dataWithBytesNoCopy:(void*)bytes length:(NSUInteger)length;
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; + (instancetype)dataWithBytesNoCopy:(void*)bytes
length:(NSUInteger)length
freeWhenDone:(BOOL)b;
@end @end
@implementation NSData @implementation NSData
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length { + (instancetype)dataWithBytesNoCopy:(void*)bytes length:(NSUInteger)length {
return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES]; return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES];
} }
+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b { + (instancetype)dataWithBytesNoCopy:(void*)bytes
NSData* data = __objc_alloc(self); length:(NSUInteger)length
if (data) { freeWhenDone:(BOOL)b {
data->_bytes = bytes; NSData* data = __objc_alloc(self);
return data; if (data) {
} data->_bytes = bytes;
else return nil; return data;
} else
return nil;
} }
- (void) dealloc { - (void)dealloc {
if (self) if (self)
free(self->_bytes); free(self->_bytes);
} }
@end @end

@ -16,7 +16,7 @@
@implementation NSDictionary @implementation NSDictionary
+ (instancetype)dictionary { + (instancetype)dictionary {
return [NSDictionary alloc]; return [NSDictionary alloc];
} }
@end @end

@ -20,29 +20,29 @@
- (instancetype)initWithFileDescriptor:(int)fd; - (instancetype)initWithFileDescriptor:(int)fd;
@property (nonatomic, readonly) int fileDescriptor; @property(nonatomic, readonly) int fileDescriptor;
@end @end
@implementation NSFileHandle @implementation NSFileHandle
- (instancetype)initWithFileDescriptor:(int)fd closeOnDealloc:(BOOL)closeopt { - (instancetype)initWithFileDescriptor:(int)fd closeOnDealloc:(BOOL)closeopt {
if (self) { if (self) {
self->_fileDescriptor = fd; self->_fileDescriptor = fd;
return self; return self;
} }
} }
- (instancetype)initWithFileDescriptor:(int)fd { - (instancetype)initWithFileDescriptor:(int)fd {
[self initWithFileDescriptor:fd closeOnDealloc:NO]; [self initWithFileDescriptor:fd closeOnDealloc:NO];
} }
- (void)closeFile { - (void)closeFile {
close(self->_fileDescriptor); close(self->_fileDescriptor);
} }
- (void)dealloc { - (void)dealloc {
[self closeFile]; [self closeFile];
} }
@end @end

@ -16,23 +16,22 @@
@implementation NSMutableArray @implementation NSMutableArray
- (void)setObject:(id)anObject atIndexedSubscript:(NSUInteger)index { - (void)setObject:(id)anObject atIndexedSubscript:(NSUInteger)index {
NSObject *obj = (NSObject*)anObject; NSObject* obj = (NSObject*)anObject;
id isa = obj->isa; id isa = obj->isa;
} }
- (void)addObject:(id)anObject { - (void)addObject:(id)anObject {
NSObject *obj = (NSObject*)anObject; NSObject* obj = (NSObject*)anObject;
id isa = obj->isa; id isa = obj->isa;
} }
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index { - (void)insertObject:(id)anObject atIndex:(NSUInteger)index {
NSObject *obj = (NSObject*)anObject; NSObject* obj = (NSObject*)anObject;
id isa = obj->isa; id isa = obj->isa;
} }
+ (instancetype)array { + (instancetype)array {
return [NSMutableArray alloc]; return [NSMutableArray alloc];
} }
@end @end

@ -16,21 +16,21 @@
@implementation NSMutableDictionary @implementation NSMutableDictionary
- (void)setObject:(id)object forKeyedSubscript:(id)aKey { - (void)setObject:(id)object forKeyedSubscript:(id)aKey {
NSObject *obj = (NSObject*)object; NSObject* obj = (NSObject*)object;
id isa = obj->isa; id isa = obj->isa;
NSObject *key = (NSObject*)aKey; NSObject* key = (NSObject*)aKey;
id isa2 = key->isa; id isa2 = key->isa;
} }
- (void)setObject:(id)anObject forKey:(id)aKey { - (void)setObject:(id)anObject forKey:(id)aKey {
NSObject *obj = (NSObject*)anObject; NSObject* obj = (NSObject*)anObject;
id isa = obj->isa; id isa = obj->isa;
NSObject *key = (NSObject*)aKey; NSObject* key = (NSObject*)aKey;
id isa2 = key->isa; id isa2 = key->isa;
} }
+ (instancetype)dictionary { + (instancetype)dictionary {
return [NSMutableDictionary alloc]; return [NSMutableDictionary alloc];
} }
@end @end

@ -14,39 +14,35 @@ void __set_unsubscribed_observer_attribute(id);
@interface NSNotificationCenter : NSObject @interface NSNotificationCenter : NSObject
- (void) addObserver:(id)notificationObserver - (void)addObserver:(id)notificationObserver
selector:(SEL)notificationSelector selector:(SEL)notificationSelector
name:(NSString *)notificationName name:(NSString*)notificationName
object:(id)notificationSender; object:(id)notificationSender;
- (void) removeObserver:(id)notificationObserver; - (void)removeObserver:(id)notificationObserver;
- (void) removeObserver:(id)notificationObserver - (void)removeObserver:(id)notificationObserver
name:(NSString *)notificationName name:(NSString*)notificationName
object:(id)notificationSender; object:(id)notificationSender;
@end @end
@implementation NSNotificationCenter @implementation NSNotificationCenter
- (void)addObserver:(id)notificationObserver
- (void) addObserver:(id)notificationObserver selector:(SEL)notificationSelector
selector:(SEL)notificationSelector name:(NSString*)notificationName
name:(NSString *)notificationName object:(id)notificationSender {
object:(id)notificationSender __set_observer_attribute(notificationObserver);
{
__set_observer_attribute(notificationObserver);
} }
- (void) removeObserver:(id)notificationObserver - (void)removeObserver:(id)notificationObserver {
{ __set_unsubscribed_observer_attribute(notificationObserver);
__set_unsubscribed_observer_attribute(notificationObserver);
} }
- (void) removeObserver:(id)notificationObserver - (void)removeObserver:(id)notificationObserver
name:(NSString *)notificationName name:(NSString*)notificationName
object:(id)notificationSender object:(id)notificationSender {
{ __set_unsubscribed_observer_attribute(notificationObserver);
__set_unsubscribed_observer_attribute(notificationObserver);
} }
@end @end

@ -10,7 +10,7 @@
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
@interface NSNumber : NSObject { @interface NSNumber : NSObject {
double value; double value;
} }
@end @end

@ -9,51 +9,50 @@
#import "NSNumber.h" #import "NSNumber.h"
@implementation NSNumber @implementation NSNumber
+(NSNumber *)numberWithInt:(int)value { + (NSNumber*)numberWithInt:(int)value {
// using alloc as the documentation doesn't say it may return nil // using alloc as the documentation doesn't say it may return nil
NSNumber *number = [self alloc]; NSNumber* number = [self alloc];
return [number initWithInt:value]; return [number initWithInt:value];
} }
- (id)initWithInt:(int)v { - (id)initWithInt:(int)v {
self->value = (double)v; self->value = (double)v;
return self; return self;
} }
+(NSNumber *)numberWithFloat:(float)value { + (NSNumber*)numberWithFloat:(float)value {
// using alloc as the documentation doesn't say it may return nil // using alloc as the documentation doesn't say it may return nil
NSNumber *number = [NSNumber alloc]; NSNumber* number = [NSNumber alloc];
return [number initWithInt:value]; return [number initWithInt:value];
} }
- (id)initWithFloat:(float)v { - (id)initWithFloat:(float)v {
self->value = (double)v; self->value = (double)v;
return self; return self;
} }
+(NSNumber *)numberWithDouble:(double)value { + (NSNumber*)numberWithDouble:(double)value {
// using alloc as the documentation doesn't say it may return nil // using alloc as the documentation doesn't say it may return nil
NSNumber *number = [self alloc]; NSNumber* number = [self alloc];
return [number initWithInt:value]; return [number initWithInt:value];
} }
- (id)initWithDouble:(double)v { - (id)initWithDouble:(double)v {
self->value = v; self->value = v;
return self; return self;
} }
+(NSNumber *)numberWithBool:(BOOL)value { + (NSNumber*)numberWithBool:(BOOL)value {
// using alloc as the documentation doesn't say it may return nil // using alloc as the documentation doesn't say it may return nil
NSNumber *number = [self alloc]; NSNumber* number = [self alloc];
return [number initWithBool:value]; return [number initWithBool:value];
} }
- (id)initWithBool:(BOOL)v { - (id)initWithBool:(BOOL)v {
self->value = (double)v; self->value = (double)v;
return self; return self;
} }
@end @end

@ -18,6 +18,6 @@
@implementation NSObject @implementation NSObject
- (id)init { - (id)init {
return (id)self; return (id)self;
} }
@end @end

@ -7,39 +7,28 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/NSObject.h>
#import <Foundation/NSDate.h> #import <Foundation/NSDate.h>
#import <Foundation/NSObject.h>
@class NSTimer; @class NSTimer;
@interface NSRunLoop : NSObject @interface NSRunLoop : NSObject
+ (NSRunLoop*) currentRunLoop; + (NSRunLoop*)currentRunLoop;
+ (NSRunLoop*) mainRunLoop; + (NSRunLoop*)mainRunLoop;
- (void)acceptInputForMode:(NSString*)mode beforeDate:(NSDate*)limit_date;
- (void) acceptInputForMode: (NSString*)mode - (void)addTimer:(NSTimer*)timer forMode:(NSString*)mode;
beforeDate: (NSDate*)limit_date;
- (void) addTimer: (NSTimer*)timer - (NSString*)currentMode;
forMode: (NSString*)mode;
- (NSString*) currentMode; - (NSDate*)limitDateForMode:(NSString*)mode;
- (NSDate*) limitDateForMode: (NSString*)mode; - (void)run;
- (void) run; - (BOOL)runMode:(NSString*)mode beforeDate:(NSDate*)date;
- (BOOL) runMode: (NSString*)mode - (void)runUntilDate:(NSDate*)date;
beforeDate: (NSDate*)date;
- (void) runUntilDate: (NSDate*)date;
@end @end

@ -7,50 +7,44 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import "NSRunLoop.h" #import "NSRunLoop.h"
@implementation NSRunLoop @implementation NSRunLoop
+ (NSRunLoop*) currentRunLoop { + (NSRunLoop*)currentRunLoop {
return [NSRunLoop alloc]; return [NSRunLoop alloc];
}; };
+ (NSRunLoop*) mainRunLoop { + (NSRunLoop*)mainRunLoop {
return [NSRunLoop alloc]; return [NSRunLoop alloc];
}; };
- (void)acceptInputForMode:(NSString*)mode beforeDate:(NSDate*)limit_date{};
- (void) acceptInputForMode: (NSString*)mode - (void)addTimer:(NSTimer*)timer
beforeDate: (NSDate*)limit_date { forMode:(NSString*)mode{
};
- (void) addTimer: (NSTimer*)timer };
forMode: (NSString*)mode {
- (NSString*)currentMode {
return @"";
}; };
- (NSString*) currentMode { - (NSDate*)limitDateForMode:(NSString*)mode {
return @"";
};
- (NSDate*) limitDateForMode: (NSString*)mode { return [NSDate alloc];
return [NSDate alloc];
}; };
- (void) run {}; - (void)run{};
- (BOOL) runMode: (NSString*)mode - (BOOL)runMode:(NSString*)mode beforeDate:(NSDate*)date {
beforeDate: (NSDate*)date {
int res; int res;
return res; return res;
}; };
- (void) runUntilDate: (NSDate*)date {}; - (void)runUntilDate:(NSDate*)date{};
@end @end

@ -10,9 +10,9 @@
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
@interface NSString : NSObject { @interface NSString : NSObject {
const char * value; const char* value;
} }
+ (instancetype)stringWithUTF8String:(const char *)bytes; + (instancetype)stringWithUTF8String:(const char*)bytes;
@end @end

@ -14,24 +14,23 @@ void __get_array_size(const UInt8);
@implementation NSString @implementation NSString
+ (instancetype)stringWithUTF8String:(const char *)bytes { + (instancetype)stringWithUTF8String:(const char*)bytes {
// using alloc as the documentation doesn't say it may return nil // using alloc as the documentation doesn't say it may return nil
NSString *s = [NSString alloc]; NSString* s = [NSString alloc];
s->value = bytes; s->value = bytes;
return s; return s;
} }
- (instancetype)initWithBytesNoCopy:(char*)bytes - (instancetype)initWithBytesNoCopy:(char*)bytes
length:(NSUInteger)length length:(NSUInteger)length
encoding:(id)encoding encoding:(id)encoding
freeWhenDone:(BOOL)flag { freeWhenDone:(BOOL)flag {
if (flag == YES) { if (flag == YES) {
if (bytes) { if (bytes) {
__get_array_size(bytes); __get_array_size(bytes);
free(bytes); free(bytes);
} }
} }
return self; return self;
} }
@end @end

@ -11,49 +11,47 @@
@class NSInvocation; @class NSInvocation;
@interface NSTimer : NSObject {
@interface NSTimer : NSObject NSTimeInterval _interval;
{ id _info;
NSTimeInterval _interval; id _target;
id _info; SEL _selector;
id _target; unsigned _repeats : 2;
SEL _selector; unsigned _timer_filler : 6;
unsigned _repeats:2; @public
unsigned _timer_filler:6; NSDate* _fireDate;
@public BOOL _is_valid;
NSDate *_fireDate;
BOOL _is_valid;
} }
+ (NSTimer *) scheduledTimerWithTimeInterval:(NSTimeInterval) ti + (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti
invocation:(NSInvocation *) invocation invocation:(NSInvocation*)invocation
repeats:(BOOL) f; repeats:(BOOL)f;
+ (NSTimer *) scheduledTimerWithTimeInterval:(NSTimeInterval) ti + (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti
target:(id) object target:(id)object
selector:(SEL) selector selector:(SEL)selector
userInfo:(id) info userInfo:(id)info
repeats:(BOOL) f; repeats:(BOOL)f;
+ (NSTimer *) timerWithTimeInterval:(NSTimeInterval) ti + (NSTimer*)timerWithTimeInterval:(NSTimeInterval)ti
invocation:(NSInvocation *) invocation invocation:(NSInvocation*)invocation
repeats:(BOOL) f; repeats:(BOOL)f;
+ (NSTimer *) timerWithTimeInterval:(NSTimeInterval) ti + (NSTimer*)timerWithTimeInterval:(NSTimeInterval)ti
target:(id) object target:(id)object
selector:(SEL) selector selector:(SEL)selector
userInfo:(id) info userInfo:(id)info
repeats:(BOOL) f; repeats:(BOOL)f;
- (void) fire; - (void)fire;
- (NSDate *) fireDate; - (NSDate*)fireDate;
- (id) initWithFireDate:(NSDate *) date - (id)initWithFireDate:(NSDate*)date
interval:(NSTimeInterval) seconds interval:(NSTimeInterval)seconds
target:(id) target target:(id)target
selector:(SEL) aSelector selector:(SEL)aSelector
userInfo:(id) userInfo userInfo:(id)userInfo
repeats:(BOOL) repeats; repeats:(BOOL)repeats;
- (void) invalidate; - (void)invalidate;
- (BOOL) isValid; - (BOOL)isValid;
- (void) setFireDate:(NSDate *) date; - (void)setFireDate:(NSDate*)date;
- (NSTimeInterval) timeInterval; - (NSTimeInterval)timeInterval;
- (id) userInfo; - (id)userInfo;
@end @end

@ -13,132 +13,117 @@
// Note: we do not link timers to NSRunLoop as this is irrelevant for // Note: we do not link timers to NSRunLoop as this is irrelevant for
// our models. If at some point becomes important it needs to be changed. // our models. If at some point becomes important it needs to be changed.
void free(void* ptr);
void free(void *ptr);
@implementation NSTimer @implementation NSTimer
+ (NSTimer*) timerWithTimeInterval:(NSTimeInterval)seconds + (NSTimer*)timerWithTimeInterval:(NSTimeInterval)seconds
invocation:(NSInvocation *)invocation invocation:(NSInvocation*)invocation
repeats:(BOOL)f repeats:(BOOL)f {
{ NSTimer* t = [self alloc];
NSTimer *t = [self alloc]; if (t) {
if(t) t->_interval = seconds;
{ t->_fireDate = [NSDate alloc];
t->_interval = seconds; t->_is_valid = YES;
t->_fireDate = [NSDate alloc]; t->_target = invocation;
t->_is_valid = YES; t->_repeats = f;
t->_target = invocation; }
t->_repeats = f; return t;
}
return t;
} }
+ (NSTimer*) timerWithTimeInterval:(NSTimeInterval)seconds + (NSTimer*)timerWithTimeInterval:(NSTimeInterval)seconds
target:(id)object target:(id)object
selector:(SEL)selector selector:(SEL)selector
userInfo:(id)info userInfo:(id)info
repeats:(BOOL)f repeats:(BOOL)f {
{ NSDate* d = [NSDate alloc];
NSDate *d = [NSDate alloc]; return [[self alloc] initWithFireDate:d
return [[self alloc] initWithFireDate:d interval:seconds
interval:seconds target:object
target:object selector:selector
selector:selector userInfo:info
userInfo:info repeats:f];
repeats:f];
} }
+ (NSTimer*) scheduledTimerWithTimeInterval:(NSTimeInterval)ti + (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti
invocation:(NSInvocation *)invocation invocation:(NSInvocation*)invocation
repeats:(BOOL)f repeats:(BOOL)f {
{ NSTimer* t = [self timerWithTimeInterval:ti invocation:invocation repeats:f];
NSTimer *t = [self timerWithTimeInterval:ti invocation:invocation repeats:f]; return t;
return t;
} }
+ (NSTimer*) scheduledTimerWithTimeInterval:(NSTimeInterval)ti + (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti
target:(id)object target:(id)object
selector:(SEL)selector selector:(SEL)selector
userInfo:(id)info userInfo:(id)info
repeats:(BOOL)f repeats:(BOOL)f {
{ NSTimer* t = [self timerWithTimeInterval:ti
NSTimer *t = [self timerWithTimeInterval: ti target:object
target: object selector:selector
selector: selector userInfo:info
userInfo: info repeats:f];
repeats: f]; return t;
return t;
} }
- (id) initWithFireDate:(NSDate *) date - (id)initWithFireDate:(NSDate*)date
interval:(NSTimeInterval)seconds interval:(NSTimeInterval)seconds
target:(id)object target:(id)object
selector:(SEL)selector selector:(SEL)selector
userInfo:(id)info userInfo:(id)info
repeats:(BOOL)f repeats:(BOOL)f {
{ _interval = seconds;
_interval = seconds; _fireDate = date;
_fireDate = date; _is_valid = YES;
_is_valid = YES; _selector = selector;
_selector = selector; _target = object;
_target = object; _info = info;
_info = info; _repeats = f;
_repeats = f;
return self;
return self;
} }
- (void) dealloc - (void)dealloc {
{ _fireDate = nil;
_fireDate=nil; free(self);
free(self);
} }
- (NSString *) description; - (NSString*)description;
{ { return [NSString alloc]; }
return [NSString alloc];
}
// Abstract everything except making the timer invalid if // Abstract everything except making the timer invalid if
// cannot repeat // cannot repeat
- (void) fire - (void)fire {
{ if (!_repeats)
if(!_repeats)
_is_valid = NO;
}
- (void) invalidate
{
_is_valid = NO; _is_valid = NO;
} }
- (BOOL) isValid { - (void)invalidate {
return _is_valid; _is_valid = NO;
} }
- (NSDate *) fireDate { - (BOOL)isValid {
return _is_valid;
return _fireDate;
} }
- (NSTimeInterval) timeInterval { - (NSDate*)fireDate {
return _interval;
return _fireDate;
} }
- (id) userInfo { - (NSTimeInterval)timeInterval {
return _info; return _interval;
} }
- (void) setFireDate:(NSDate *)date; - (id)userInfo {
{ return _info;
_fireDate =date;
} }
- (int) compare:(NSTimer*)anotherTimer - (void)setFireDate:(NSDate*)date;
{ { _fireDate = date; }
int res;
return res; - (int)compare:(NSTimer*)anotherTimer {
int res;
return res;
} }
@end @end

@ -8,58 +8,57 @@
*/ */
#include "clang/Frontend/FrontendPluginRegistry.h" #include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/AST.h" #include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInstance.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
using namespace clang; using namespace clang;
namespace { namespace {
class PrintFunctionsConsumer : public ASTConsumer { class PrintFunctionsConsumer : public ASTConsumer {
public: public:
virtual bool HandleTopLevelDecl(DeclGroupRef DG) { virtual bool HandleTopLevelDecl(DeclGroupRef DG) {
for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) { for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
const Decl *D = *i; const Decl* D = *i;
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) if (const NamedDecl* ND = dyn_cast<NamedDecl>(D))
llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n"; llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
}
return true;
} }
};
class PrintFunctionNamesAction : public PluginASTAction { return true;
protected: }
ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) { };
return new PrintFunctionsConsumer();
}
bool ParseArgs(const CompilerInstance &CI, class PrintFunctionNamesAction : public PluginASTAction {
const std::vector<std::string>& args) { protected:
for (unsigned i = 0, e = args.size(); i != e; ++i) { ASTConsumer* CreateASTConsumer(CompilerInstance& CI, llvm::StringRef) {
llvm::errs() << "toplevel-plugin arg = " << args[i] << "\n"; return new PrintFunctionsConsumer();
}
// Example error handling. bool ParseArgs(const CompilerInstance& CI,
if (args[i] == "-an-error") { const std::vector<std::string>& args) {
DiagnosticsEngine &D = CI.getDiagnostics(); for (unsigned i = 0, e = args.size(); i != e; ++i) {
unsigned DiagID = D.getCustomDiagID( llvm::errs() << "toplevel-plugin arg = " << args[i] << "\n";
DiagnosticsEngine::Error, "invalid argument '" + args[i] + "'");
D.Report(DiagID);
return false;
}
}
if (args.size() && args[0] == "help")
PrintHelp(llvm::errs());
return true; // Example error handling.
} if (args[i] == "-an-error") {
void PrintHelp(llvm::raw_ostream& ros) { DiagnosticsEngine& D = CI.getDiagnostics();
ros << "Help for toplevel-plugin plugin goes here\n"; unsigned DiagID = D.getCustomDiagID(
DiagnosticsEngine::Error, "invalid argument '" + args[i] + "'");
D.Report(DiagID);
return false;
}
} }
if (args.size() && args[0] == "help")
PrintHelp(llvm::errs());
}; return true;
}
void PrintHelp(llvm::raw_ostream& ros) {
ros << "Help for toplevel-plugin plugin goes here\n";
}
};
} }
static FrontendPluginRegistry::Add<PrintFunctionNamesAction> X("infer-plugin", "print function names"); static FrontendPluginRegistry::Add<PrintFunctionNamesAction> X(
"infer-plugin", "print function names");

@ -7,12 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
void simple_check(int x) { void simple_check(int x) { assert(x < 3); }
assert(x < 3);
}
void simple_assertion_failure() { void simple_assertion_failure() {
int x = 4; int x = 4;
@ -24,16 +22,12 @@ void no_assertion_failure() {
simple_check(x); simple_check(x);
} }
typedef struct { typedef struct { int value; } node;
int value;
} node;
void check_node(node *n) { void check_node(node* n) { assert(n->value < 3); }
assert(n->value < 3);
}
node* assertion_failure_with_heap() { node* assertion_failure_with_heap() {
node *n = malloc(sizeof(node)); node* n = malloc(sizeof(node));
if (n != NULL) { if (n != NULL) {
n->value = 4; n->value = 4;
check_node(n); check_node(n);
@ -42,7 +36,7 @@ node* assertion_failure_with_heap() {
} }
node* no_assertion_failure_with_heap() { node* no_assertion_failure_with_heap() {
node *n = malloc(sizeof(node)); node* n = malloc(sizeof(node));
if (n != NULL) { if (n != NULL) {
n->value = 2; n->value = 2;
check_node(n); check_node(n);
@ -58,9 +52,7 @@ void my_assert(int x) {
} }
} }
void should_not_report_assertion_failure(int x) { void should_not_report_assertion_failure(int x) { my_assert(x); }
my_assert(x);
}
void should_report_assertion_failure(int x) { void should_report_assertion_failure(int x) {
x = 0; x = 0;
@ -69,9 +61,7 @@ void should_report_assertion_failure(int x) {
int global; int global;
void check_global() { void check_global() { assert(global != 0); }
assert(global != 0);
}
void skip() {} void skip() {}

@ -11,14 +11,14 @@
extern int add_all_ints(int x, int y, int z, ...) __attribute__((sentinel)); extern int add_all_ints(int x, int y, int z, ...) __attribute__((sentinel));
void valid_call(int *a, int *b, int *c) { void valid_call(int* a, int* b, int* c) {
// fine // fine
int x = add_all_ints(0, 0, 0, a, b, c, NULL); int x = add_all_ints(0, 0, 0, a, b, c, NULL);
} }
void truncated_call(void) { void truncated_call(void) {
int a = 0, b = 1, c = 2, d = 3; int a = 0, b = 1, c = 2, d = 3;
int *p = NULL; int* p = NULL;
// warning: p is NULL so only first argument sent to add_all_ints // warning: p is NULL so only first argument sent to add_all_ints
int x = add_all_ints(0, 0, 0, &a, p, &b, &c, &d, NULL); int x = add_all_ints(0, 0, 0, &a, p, &b, &c, &d, NULL);

@ -12,7 +12,8 @@
void __infer_fail(char*); void __infer_fail(char*);
void check_exponent(int x) { void check_exponent(int x) {
if (x < 0) __infer_fail("UNEXPECTED_NEGATIVE_EXPONENT"); if (x < 0)
__infer_fail("UNEXPECTED_NEGATIVE_EXPONENT");
} }
int power(int x) { int power(int x) {
@ -32,9 +33,7 @@ int paf() {
int global; int global;
void set_global() { void set_global() { global = -2; }
global = -2;
}
int pouf() { int pouf() {
set_global(); set_global();

@ -10,32 +10,32 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int *set42(int* x) { int* set42(int* x) {
*x = 42; *x = 42;
return x; return x;
} }
void nodpd () { void nodpd() {
int w,*z; int w, *z;
z = set42(&w); z = set42(&w);
} }
void nodpd1 () { void nodpd1() {
int *y = malloc(sizeof(int)); int* y = malloc(sizeof(int));
int *z; int* z;
z = set42(y); z = set42(y);
free(y); free(y);
} }
void dpd () { void dpd() {
int *y; int* y;
int *z; int* z;
z = set42(y); z = set42(y);
} }
void intraprocdpd () { void intraprocdpd() {
int *y; int* y;
int *z; int* z;
*y = 42; *y = 42;
z = y; z = y;
} }

@ -12,10 +12,6 @@ struct point {
int y; int y;
}; };
int return_zero() { int return_zero() { return ((struct point){.y = 32, .x = 0}).x; }
return ((struct point) { .y = 32, .x = 0 }).x;
}
int divide_by_zero() { int divide_by_zero() { return 1 / return_zero(); }
return 1/return_zero();
}

@ -8,6 +8,6 @@
*/ */
int init_divide_by_zero() { int init_divide_by_zero() {
int t[2][3][2] = {{{1,1},{2,2},{3,3}},{{4,4},{5,5},{1,0}}}; int t[2][3][2] = {{{1, 1}, {2, 2}, {3, 3}}, {{4, 4}, {5, 5}, {1, 0}}};
return t[0][1][0]/t[1][2][1]; return t[0][1][0] / t[1][2][1];
} }

@ -8,20 +8,20 @@
*/ */
struct l2 { struct l2 {
int b; int b;
struct l2 *a; struct l2* a;
}; };
int add2(struct l2 *l) { int add2(struct l2* l) {
int r = 0; int r = 0;
for (; l; l = l->a) { for (; l; l = l->a) {
r += l->b; r += l->b;
} }
return r; return r;
} }
/* Divide by zero error shows that we get a spec for add2 */ /* Divide by zero error shows that we get a spec for add2 */
int main() { int main() {
int res = add2(0); int res = add2(0);
return 5/res; return 5 / res;
} }

@ -7,40 +7,45 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
int m(int z) { int m(int z) {
int y = 0; int y = 0;
int x = 5; int x = 5;
if (z < 10) { if (z < 10) {
int x = 7; int x = 7;
if (x == 7) return x/y; if (x == 7)
} return x / y;
if (x == 5) }
return x/y; if (x == 5)
else return 0; return x / y;
else
return 0;
} }
int mm() { int mm() {
int y = 0; int y = 0;
int x = 0; int x = 0;
{ {
int x = 5; int x = 5;
if (x == 5) return x/y; if (x == 5)
} return x / y;
if (x == 0) }
return x/y; if (x == 0)
else return 0; return x / y;
else
return 0;
} }
int t() { int t() {
int y = 0; int y = 0;
int x = 1; int x = 1;
int z = 0; int z = 0;
for (int x = 0; x < 10; x++) { for (int x = 0; x < 10; x++) {
int x = 9; int x = 9;
if (x == 9) return x/y; if (x == 9)
else return 0; return x / y;
} else
return 0; return 0;
}
return 0;
} }

@ -11,32 +11,31 @@
#include <string.h> #include <string.h>
void simple_leak() { void simple_leak() {
int *p; int* p;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
} }
void common_realloc_leak() { void common_realloc_leak() {
int *p, *q; int *p, *q;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
q = (int*) realloc(p, sizeof(int) * 42); q = (int*)realloc(p, sizeof(int) * 42);
// if realloc fails, then p becomes unreachable // if realloc fails, then p becomes unreachable
if (q != NULL) free(q); if (q != NULL)
free(q);
} }
int* allocate() { int* allocate() {
int *p = NULL; int* p = NULL;
do { do {
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
} while (p == NULL); } while (p == NULL);
return p; return p;
} }
void uses_allocator() { void uses_allocator() {
int *p; int* p;
p = allocate(); p = allocate();
*p = 42; *p = 42;
} }
void * builtin_no_leak(size_t s) { void* builtin_no_leak(size_t s) { return memset(malloc(s), 0, s); }
return memset(malloc(s), 0, s);
}

@ -13,17 +13,17 @@ struct delicious {
int yum; int yum;
}; };
struct delicious *bake(struct delicious **cake) { struct delicious* bake(struct delicious** cake) {
int *zero = NULL; int* zero = NULL;
*zero = 3; *zero = 3;
return NULL; return NULL;
} }
struct delicious *skip_function_with_no_spec(void) { struct delicious* skip_function_with_no_spec(void) {
struct delicious *cake = NULL; struct delicious* cake = NULL;
int i; int i;
if(bake(&cake) == NULL) { if (bake(&cake) == NULL) {
return 0; return 0;
} }
@ -31,17 +31,17 @@ struct delicious *skip_function_with_no_spec(void) {
return cake; return cake;
} }
extern struct delicious *bakery(struct delicious **cake); extern struct delicious* bakery(struct delicious** cake);
extern struct delicious *bakery2(struct delicious **cake, extern struct delicious* bakery2(struct delicious** cake,
struct delicious **pie); struct delicious** pie);
extern struct delicious *returnPassByRef(); extern struct delicious* returnPassByRef();
extern void skip(struct delicious * s); extern void skip(struct delicious* s);
struct delicious *skip_external_function(void) { struct delicious* skip_external_function(void) {
struct delicious *cake = NULL; struct delicious* cake = NULL;
int i; int i;
if(bakery(&cake) == NULL) { if (bakery(&cake) == NULL) {
return 0; return 0;
} }
@ -49,9 +49,9 @@ struct delicious *skip_external_function(void) {
return cake; return cake;
} }
void by_ref_actual_already_in_footprint(struct delicious *param) { void by_ref_actual_already_in_footprint(struct delicious* param) {
int i; int i;
struct delicious * ret = bakery(&param); struct delicious* ret = bakery(&param);
i = param->yum; i = param->yum;
} }
@ -59,11 +59,11 @@ void call_by_ref_actual_already_in_footprint_ok() {
by_ref_actual_already_in_footprint(NULL); // should not report a warning by_ref_actual_already_in_footprint(NULL); // should not report a warning
} }
void by_ref_actual_already_in_footprint2(struct delicious *param) { void by_ref_actual_already_in_footprint2(struct delicious* param) {
int i; int i;
i = param->yum; // should not report a warning i = param->yum; // should not report a warning
struct delicious * ret = bakery(&param); struct delicious* ret = bakery(&param);
i = param->yum; // should not report a warning i = param->yum; // should not report a warning
} }
void call_by_ref_actual_already_in_footprint_bad() { void call_by_ref_actual_already_in_footprint_bad() {
@ -71,20 +71,20 @@ void call_by_ref_actual_already_in_footprint_bad() {
} }
void passByRefTwice() { void passByRefTwice() {
struct delicious *param; struct delicious* param;
bakery2(&param, &param); // should not report a warning bakery2(&param, &param); // should not report a warning
int i = param->yum; int i = param->yum;
} }
struct delicious * returnPassByRef2() { struct delicious* returnPassByRef2() {
struct delicious *param = NULL; struct delicious* param = NULL;
bakery(&param); bakery(&param);
int i = param->yum; // should not report a warning int i = param->yum; // should not report a warning
return param; return param;
} }
void returnPassByRefDeref() { void returnPassByRefDeref() {
struct delicious *ret = returnPassByRef(); struct delicious* ret = returnPassByRef();
ret->yum = 2; // should not report a warning ret->yum = 2; // should not report a warning
free(ret); free(ret);
} }

@ -11,392 +11,338 @@
#include <stdlib.h> #include <stdlib.h>
void crash_getc() { void crash_getc() {
FILE *f; FILE* f;
int i; int i;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
i = getc(f);
printf("i =%i\n", i);
fclose(f);
}
void nocrash_getc() {
FILE* f;
int i;
f = fopen("this_file_doesnt_exist", "r");
if (f) {
i = getc(f); i = getc(f);
printf("i =%i\n", i); printf("i =%i\n", i);
fclose(f); fclose(f);
}
} }
void nocrash_getc() { void crash_fgetc() {
FILE *f; FILE* f;
int i; int i;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { i = fgetc(f);
i = getc(f); printf("i =%i\n", i);
printf("i =%i\n", i); fclose(f);
fclose(f);
}
} }
void crash_fgetc() { void nocrash_fgetc() {
FILE *f; FILE* f;
int i; int i;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
i = fgetc(f); i = fgetc(f);
printf("i =%i\n", i); printf("i =%i\n", i);
fclose(f); fclose(f);
}
} }
void nocrash_fgetc() { void crash_ungetc() {
FILE *f; FILE* f;
int i;
f = fopen("this_file_doesnt_exist", "r");
if (f) {
i = fgetc(f);
printf("i =%i\n", i);
fclose(f);
}
}
f = fopen("this_file_doesnt_exist", "r");
void crash_ungetc() int i = ungetc(10, f);
{ fclose(f);
FILE *f; }
f = fopen("this_file_doesnt_exist", "r"); void nocrash_ungetc() {
FILE* f;
int i =ungetc(10,f); f = fopen("this_file_doesnt_exist", "r");
if (f) {
int i = ungetc(10, f);
fclose(f); fclose(f);
}
} }
void nocrash_ungetc() void crash_fputs() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fputs("blablabla", f);
int i =ungetc(10,f); fclose(f);
fclose(f);
}
} }
void crash_fputs() void nocrash_fputs() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
fputs("blablabla", f); fputs("blablabla", f);
fclose(f); fclose(f);
}
} }
void nocrash_fputs() void crash_fputc() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fputc(42, f);
fputs("blablabla", f); fclose(f);
fclose(f);
}
} }
void crash_fputc() void nocrash_fputc() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
fputc(42, f); fputc(42, f);
fclose(f); fclose(f);
}
} }
void nocrash_fputc() void crash_putc() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { putc(42, f);
fputc(42, f); fclose(f);
fclose(f);
}
} }
void crash_putc() void nocrash_putc() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
putc(42, f); putc(42, f);
fclose(f); fclose(f);
}
} }
void nocrash_putc() void crash_fseeks() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fseek(f, 7, SEEK_SET);
putc(42, f); fclose(f);
fclose(f);
}
} }
void crash_fseeks() void nocrash_fseek() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
fseek( f, 7, SEEK_SET ); if (f) {
fseek(f, 7, SEEK_SET);
fclose(f); fclose(f);
}
} }
void nocrash_fseek() void crash_ftell() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { ftell(f);
fseek( f, 7, SEEK_SET ); fclose(f);
fclose(f);
}
} }
void crash_ftell() void nocrash_ftell() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
ftell(f); ftell(f);
fclose(f); fclose(f);
}
} }
void nocrash_ftell() void crash_fgets() {
{ FILE* f;
FILE *f; char str[60];
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fgets(str, 60, f);
ftell( f); fclose(f);
fclose(f);
}
} }
void crash_fgets() void nocrash_fgets() {
{ FILE* f;
FILE *f; char str[60];
char str[60];
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
fgets(str,60, f); if (f) {
fgets(str, 60, f);
fclose(f); fclose(f);
}
} }
void nocrash_fgets() void crash_rewind() {
{ FILE* f;
FILE *f;
char str[60];
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { rewind(f);
fgets(str,60, f); fclose(f);
fclose(f);
}
} }
void nocrash_rewind() {
FILE* f;
void crash_rewind() f = fopen("this_file_doesnt_exist", "r");
{ if (f) {
FILE *f;
f = fopen("this_file_doesnt_exist", "r");
rewind(f); rewind(f);
fclose(f); fclose(f);
}
} }
void nocrash_rewind() void crash_fileno() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fileno(f);
rewind( f); fclose(f);
fclose(f);
}
} }
void crash_fileno() void nocrash_fileno() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
fileno(f); fileno(f);
fclose(f); fclose(f);
}
} }
void nocrash_fileno() void crash_clearerr() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { clearerr(f);
fileno( f); fclose(f);
fclose(f);
}
} }
void nocrash_clearerr() {
FILE* f;
void crash_clearerr() f = fopen("this_file_doesnt_exist", "r");
{ if (f) {
FILE *f;
f = fopen("this_file_doesnt_exist", "r");
clearerr(f); clearerr(f);
fclose(f); fclose(f);
}
} }
void nocrash_clearerr() void crash_ferror() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { ferror(f);
clearerr( f); fclose(f);
fclose(f);
}
} }
void crash_ferror() void nocrash_ferror() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
ferror(f); ferror(f);
fclose(f); fclose(f);
}
} }
void nocrash_ferror() void crash_feof() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { feof(f);
ferror( f); fclose(f);
fclose(f);
}
} }
void crash_feof() void nocrash_feof() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) {
feof(f); feof(f);
fclose(f); fclose(f);
}
} }
void nocrash_feof() void crash_fprintf() {
{ FILE* f;
FILE *f;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fprintf(f, "blablabla\n");
feof(f); fclose(f);
fclose(f);
}
} }
void nocrash_fprintf() {
FILE* f;
f = fopen("this_file_doesnt_exist", "r");
void crash_fprintf() if (f) {
{ fprintf(f, "blablabla\n");
FILE *f;
f = fopen("this_file_doesnt_exist", "r");
fprintf(f,"blablabla\n");
fclose(f); fclose(f);
}
} }
void nocrash_fprintf() void crash_vfprintf() {
{ FILE* f;
FILE *f; va_list arg;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { vfprintf(f, "blablabla\n", arg);
fprintf(f,"blablabla\n"); fclose(f);
fclose(f);
}
} }
void crash_vfprintf() void nocrash_vfprintf() {
{ FILE* f;
FILE *f; va_list arg;
va_list arg;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
vfprintf(f,"blablabla\n",arg); if (f) {
vfprintf(f, "blablabla\n", arg);
fclose(f); fclose(f);
}
} }
void nocrash_vfprintf() void crash_fgetpos() {
{ FILE* f;
FILE *f; fpos_t position;
va_list arg;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fgetpos(f, &position);
vfprintf(f,"blablabla\n",arg); fclose(f);
fclose(f);
}
} }
void nocrash_fgetpos() {
FILE* f;
fpos_t position;
void crash_fgetpos() f = fopen("this_file_doesnt_exist", "r");
{ if (f) {
FILE *f; fgetpos(f, &position);
fpos_t position;
f = fopen("this_file_doesnt_exist", "r");
fgetpos(f,&position);
fclose(f); fclose(f);
}
} }
void nocrash_fgetpos() void crash_fsetpos() {
{ FILE* f;
FILE *f; fpos_t position;
fpos_t position;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
if (f) { fsetpos(f, &position);
fgetpos(f,&position); fclose(f);
fclose(f);
}
} }
void crash_fsetpos() void nocrash_fsetpos() {
{ FILE* f;
FILE *f; fpos_t position;
fpos_t position;
f = fopen("this_file_doesnt_exist", "r"); f = fopen("this_file_doesnt_exist", "r");
fsetpos(f,&position); if (f) {
fsetpos(f, &position);
fclose(f); fclose(f);
}
}
void nocrash_fsetpos()
{
FILE *f;
fpos_t position;
f = fopen("this_file_doesnt_exist", "r");
if (f) {
fsetpos(f,&position);
fclose(f);
}
} }

@ -16,90 +16,86 @@ struct Person {
}; };
int simple_null_pointer() { int simple_null_pointer() {
struct Person *max = 0; struct Person* max = 0;
return max->age; return max->age;
} }
struct Person *Person_create(int age, int height, int weight) { struct Person* Person_create(int age, int height, int weight) {
struct Person *who = 0; struct Person* who = 0;
return who; return who;
} }
int get_age(struct Person *who) { int get_age(struct Person* who) { return who->age; }
return who->age;
}
int null_pointer_interproc() { int null_pointer_interproc() {
struct Person *joe = Person_create(32, 64, 140); struct Person* joe = Person_create(32, 64, 140);
return get_age(joe); return get_age(joe);
} }
int negation_in_conditional() { int negation_in_conditional() {
int *x = 0; int* x = 0;
if (!x) return 0; if (!x)
else return *x; // this never happens return 0;
else
return *x; // this never happens
} }
int * foo() { int* foo() { return 0; }
return 0;
}
void null_pointer_with_function_pointer() { void null_pointer_with_function_pointer() {
int * (*fp)(); int* (*fp)();
fp = foo; fp = foo;
int *x = fp(); int* x = fp();
*x = 3; *x = 3;
} }
void use_exit (struct Person *htbl) { void use_exit(struct Person* htbl) {
if (!htbl) if (!htbl)
exit(0); exit(0);
int x = htbl->age; int x = htbl->age;
} }
void basic_null_dereference() { void basic_null_dereference() {
int *p = NULL; int* p = NULL;
*p = 42; // NULL dereference *p = 42; // NULL dereference
} }
void no_check_for_null_after_malloc() { void no_check_for_null_after_malloc() {
int *p; int* p;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
*p = 42; // NULL dereference *p = 42; // NULL dereference
free(p); free(p);
} }
void no_check_for_null_after_realloc() { void no_check_for_null_after_realloc() {
int *p; int* p;
p = (int*) malloc(sizeof(int) * 5); p = (int*)malloc(sizeof(int) * 5);
if (p) { if (p) {
p[3] = 42; p[3] = 42;
} }
int *q = (int*) realloc(p, sizeof(int) * 10); int* q = (int*)realloc(p, sizeof(int) * 10);
if (!q) if (!q)
free(p); free(p);
q[7] = 0; // NULL dereference q[7] = 0; // NULL dereference
free(q); free(q);
} }
void assign(int *p, int n) { void assign(int* p, int n) { *p = n; }
*p = n;
}
void potentially_null_pointer_passed_as_argument() { void potentially_null_pointer_passed_as_argument() {
int *p = NULL; int* p = NULL;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
assign(p, 42); // NULL dereference assign(p, 42); // NULL dereference
free(p); free(p);
} }
void null_passed_as_argument() { void null_passed_as_argument() {
assign(NULL, 42); // NULL dereference assign(NULL, 42); // NULL dereference
} }
void allocated_pointer_passed_as_argument() { void allocated_pointer_passed_as_argument() {
int *p = NULL; int* p = NULL;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
if (p) { if (p) {
assign(p, 42); assign(p, 42);
free(p); free(p);
@ -107,28 +103,28 @@ void allocated_pointer_passed_as_argument() {
} }
int* unsafe_allocate() { int* unsafe_allocate() {
int *p = NULL; int* p = NULL;
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
return p; return p;
} }
int* safe_allocate() { int* safe_allocate() {
int *p = NULL; int* p = NULL;
while (!p) { while (!p) {
p = (int*) malloc(sizeof(int)); p = (int*)malloc(sizeof(int));
} }
return p; return p;
} }
void function_call_can_return_null_pointer() { void function_call_can_return_null_pointer() {
int *p = NULL; int* p = NULL;
p = unsafe_allocate(); p = unsafe_allocate();
assign(p, 42); // NULL dereference assign(p, 42); // NULL dereference
free(p); free(p);
} }
void function_call_returns_allocated_pointer() { void function_call_returns_allocated_pointer() {
int *p = NULL; int* p = NULL;
p = safe_allocate(); p = safe_allocate();
assign(p, 42); assign(p, 42);
free(p); free(p);

@ -14,72 +14,69 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
void fileNotClosed() {
void fileNotClosed() int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600);
{ if (fd != -1) {
int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); char buffer[256];
if (fd != -1) { // We can easily batch that by separating with space
char buffer[256]; write(fd, buffer, strlen(buffer));
// We can easily batch that by separating with space }
write(fd, buffer, strlen(buffer));
}
} }
void fileClosed() void fileClosed() {
{ int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600);
int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd != -1) {
if (fd != -1) { char buffer[256];
char buffer[256]; // We can easily batch that by separating with space
// We can easily batch that by separating with space write(fd, buffer, strlen(buffer));
write(fd, buffer, strlen(buffer)); close(fd);
close(fd); }
}
} }
void socketNotClosed() void socketNotClosed() {
{ int fd = socket(AF_LOCAL, SOCK_RAW, 0);
int fd = socket(AF_LOCAL, SOCK_RAW, 0); if (fd != -1) {
if (fd != -1) { char buffer[256];
char buffer[256]; // We can easily batch that by separating with space
// We can easily batch that by separating with space write(fd, buffer, strlen(buffer));
write(fd, buffer, strlen(buffer)); }
}
} }
int socketClosed() int socketClosed() {
{ int socketFD = socket(AF_LOCAL, SOCK_RAW, 0);
int socketFD = socket(AF_LOCAL, SOCK_RAW, 0); if (socketFD == -1) {
if (socketFD == -1) { return -1;
return -1; }
}
int status; int status;
status = fcntl(socketFD, F_SETFL, O_NONBLOCK); status = fcntl(socketFD, F_SETFL, O_NONBLOCK);
if (status == -1) { if (status == -1) {
close(socketFD); close(socketFD);
return -1; return -1;
} }
int reuseaddr = 1; int reuseaddr = 1;
status = setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)); status = setsockopt(
if (status == -1) { socketFD, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr));
close(socketFD); if (status == -1) {
return -1; close(socketFD);
} return -1;
}
int nosigpipe = 1; int nosigpipe = 1;
status = setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &nosigpipe, sizeof(nosigpipe)); status = setsockopt(
if (status == -1) { socketFD, SOL_SOCKET, SO_REUSEADDR, &nosigpipe, sizeof(nosigpipe));
close(socketFD); if (status == -1) {
return -1; close(socketFD);
} return -1;
}
return socketFD; return socketFD;
} }

@ -9,15 +9,15 @@
int main() { int main() {
int volatile a; int volatile a;
int *volatile b; int* volatile b;
float *const c; float* const c;
long double d; long double d;
static const int kDuration = 3; static const int kDuration = 3;
int large_int = 9223372036854775807; int large_int = 9223372036854775807;
int overflow_int = 9223372036854775808; int overflow_int = 9223372036854775808;
return 0; return 0;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save