Skip to content

Instantly share code, notes, and snippets.

@richo
Last active February 13, 2020 02:49
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 richo/9454b822316c70bc0e754a7f9ca62611 to your computer and use it in GitHub Desktop.
Save richo/9454b822316c70bc0e754a7f9ca62611 to your computer and use it in GitHub Desktop.
cbindgen thingy
/target
**/*.rs.bk
Cargo.lock
[package]
name = "free-thingy"
version = "0.1.0"
authors = ["Richo Healey <richo@psych0tik.net>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
header = "/* c bindings to the authlib-rs library */"
# include_guard = "AUTHLIB_RS_BINDINGS_H"
language = "C"
[parse.expand]
crates = ["free-thingy"]
[enum]
rename_variants = "QualifiedScreamingSnakeCase"
pub struct TokenSet;
macro_rules! make_free_fn {
($name:ident, $ty:ident) => {
#[no_mangle]
pub unsafe extern "C" fn $name(ptr: *mut $ty) {
if ptr.is_null() {
return;
}
Box::from_raw(ptr);
}
}
}
make_free_fn!(tokenset, TokenSet);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment