Skip to content

Commit

Permalink
chore: expose free func for model
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Dec 13, 2023
1 parent 09ee51d commit a138442
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ struct Result_bool account_execute_raw(struct Account *account,

void client_free(struct ToriiClient *t);

void jsonrpc_client_free(struct CJsonRpcClient *rpc);

void model_free(struct Model *model);

void account_free(struct Account *account);

void ty_free(struct Ty *ty);
Expand Down
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,24 @@ pub unsafe extern "C" fn client_free(t: *mut ToriiClient) {
}
}

#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn jsonrpc_client_free(rpc: *mut CJsonRpcClient) {
if !rpc.is_null() {
unsafe {
let _ = Box::from_raw(rpc);
}
}
}

#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn model_free(model: *mut Model) {
if !model.is_null() {
let _: torii_grpc::types::schema::Model = (&*Box::<Model>::from_raw(model)).into();
}
}

#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn account_free(account: *mut Account<'static>) {
Expand Down

0 comments on commit a138442

Please sign in to comment.