Skip to content

Instantly share code, notes, and snippets.

@jonathanstowe
Created May 5, 2016 16:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jonathanstowe/73dc661bbb1822441f31247784c0a345 to your computer and use it in GitHub Desktop.
use NativeCall;
my $a = 0;
class Foo is repr('CPointer') {
sub malloc(size_t $t) returns Foo is native { * }
method new() {
malloc(100);
}
sub free(Foo $t) is native { * }
method DESTROY {
say "boom ", $a++;
free(self);
}
}
loop {
say $++;
my $f = Foo.new;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment