Skip to content

Instantly share code, notes, and snippets.

@deian
Last active December 30, 2015 02:49
Show Gist options
  • Save deian/7764828 to your computer and use it in GitHub Desktop.
Save deian/7764828 to your computer and use it in GitHub Desktop.
blocks & refcount
#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