Skip to content

Commit

Permalink
get_module_functions: gc protect CppFunctionInfo struct during push_back
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz authored and barche committed Dec 12, 2024
1 parent 46cb3b2 commit b36e1e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/c_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
{
Array<jl_value_t*> arg_default_values_array;
jl_value_t* boxed_n_kwargs = nullptr;
JL_GC_PUSH2(arg_default_values_array.gc_pointer(), &boxed_n_kwargs);
jl_value_t* cppfuncinfo = nullptr;
JL_GC_PUSH3(arg_default_values_array.gc_pointer(), &boxed_n_kwargs, &cppfuncinfo);

fill_types_vec(arg_types_array, f.argument_types());

Expand All @@ -169,7 +170,7 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
julia_return_type = ccall_return_type;
}

function_array.push_back(jl_new_struct(g_cppfunctioninfo_type,
cppfuncinfo = jl_new_struct(g_cppfunctioninfo_type,
f.name(),
arg_types_array.wrapped(),
ccall_return_type,
Expand All @@ -181,7 +182,8 @@ JLCXX_API jl_array_t* get_module_functions(jl_module_t* jlmod)
arg_names_array.wrapped(),
arg_default_values_array.wrapped(),
boxed_n_kwargs
));
);
function_array.push_back(cppfuncinfo);
JL_GC_POP();
}
JL_GC_POP();
Expand Down

0 comments on commit b36e1e0

Please sign in to comment.