mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-01 19:02:19 +00:00
correct dropping of return pointer from exposed functions
This commit is contained in:
parent
856b38a958
commit
9248e1853b
1 changed files with 5 additions and 1 deletions
|
@ -3629,7 +3629,11 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx, 'env>(
|
|||
let (params, param_types) = match (&roc_return, &cc_return) {
|
||||
// Drop the "return pointer" if it exists on the roc function
|
||||
// and the c function does not return via pointer
|
||||
(RocReturn::ByPointer, CCReturn::Return) => (¶ms[..], ¶m_types[1..]),
|
||||
(RocReturn::ByPointer, CCReturn::Return) => {
|
||||
// Roc current puts the return pointer at the end of the argument list.
|
||||
// As such, we drop the last element here instead of the first.
|
||||
(¶ms[..], ¶m_types[..param_types.len() - 1])
|
||||
}
|
||||
// Drop the return pointer the other way, if the C function returns by pointer but Roc
|
||||
// doesn't
|
||||
(RocReturn::Return, CCReturn::ByPointer) => (¶ms[1..], ¶m_types[..]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue