Skip to content

Commit

Permalink
test __NSAutoreleaseNoPool
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Feb 18, 2014
1 parent 655d783 commit 2cefd35
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test_NSAutoreleaseNoPool.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// compile:
// c++ -framework CoreFoundation -framework Foundation test_NSAutoreleaseNoPool.mm

#include <dlfcn.h>
#include <stdio.h>
#import <Foundation/Foundation.h>

typedef void (*NSAutoreleaseNoPoolFunc) (void* obj);

void foo() {
NSAutoreleaseNoPoolFunc __NSAutoreleaseNoPool = (NSAutoreleaseNoPoolFunc) dlsym(RTLD_DEFAULT, "__NSAutoreleaseNoPool");
printf("func: %p\n", __NSAutoreleaseNoPool);
}

id raiseNoPool() {
NSString* foo = [[NSString alloc] init];
return [foo autorelease];
}

void bar() {
id x = raiseNoPool();
}

int main() {
foo();
bar();
return 0;
}

0 comments on commit 2cefd35

Please sign in to comment.