Skip to content

Commit

Permalink
deallocate arguments in canonical ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
cpetig committed Sep 12, 2024
1 parent 5d2bfb8 commit ccaf0ca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,9 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
r#"auto {result} = wit::vector<{vtype}>::allocate({len});
"#,
));
if self.gen.gen.opts.new_api && matches!(self.variant, AbiVariant::GuestExport) {
self.push_str(&format!("if ({len}>0) _deallocate.push_back({base});\n"));
}

uwriteln!(self.src, "for (unsigned i=0; i<{len}; ++i) {{");
uwriteln!(
Expand Down

0 comments on commit ccaf0ca

Please sign in to comment.