Skip to content

Instantly share code, notes, and snippets.

@niner
Forked from bpetering/test.c
Last active January 2, 2016 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niner/6cc82bfcbb6615acadd0 to your computer and use it in GitHub Desktop.
Save niner/6cc82bfcbb6615acadd0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
struct foo {
int x;
};
void foo_init(struct foo **f) {
*f = malloc(sizeof(struct foo));
printf("malloc'd, pointer = %p\n", (void *) *f);
}
void foo_shutdown(struct foo *f) {
printf("freeing, pointer = %p\n", (void *) f);
free(f);
}
void foo_test() { printf("foo\n"); }
use NativeCall;
class foo is repr('CPointer') { }
sub foo_init(foo is rw)
is native('./test')
{ * }
sub foo_shutdown(foo)
is native('./test')
{ * }
my foo $p = foo.new;
foo_init($p);
foo_shutdown($p);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment