Last active
December 30, 2015 02:49
-
-
Save deian/7764828 to your computer and use it in GitHub Desktop.
blocks & refcount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Block.h> | |
typedef void (^voidToVoid) (void); | |
typedef void (^voidToVoidToVoid) (voidToVoid); | |
void f(void) { | |
voidToVoidToVoid a = ^ (voidToVoid b) { | |
voidToVoid b2 = Block_copy(b); | |
printf("a\n"); | |
b(); | |
Block_release(b2); | |
}; | |
voidToVoid b = ^ { | |
voidToVoidToVoid a2 = Block_copy(a); | |
printf("b\n"); | |
Block_release(a2); | |
}; | |
a(b); | |
} | |
int main(void) { | |
f(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment