On 23/03/02 23:52 +0100, david Ramboz wrote:
>
>
> Hello,
>
> How do you call several times a callback
> in perl from C.
> I've tried the following code with no
> success (it works 1, 2 times and then
> gives me out of memory errors)
David,
Even though the C-Cookbook says to do this, don't. Don't use
Inline_Stack_Vars to call back to Perl. They don't quite do the right thing.
Read 'perldoc perlcall' for a full explanation on this subject. In a future
release of Inline I will either fix these macros or fix the cookbook or both.
Cheers, Brian
>
>
> char *static_callback = "main::test";
>
> void call_callback (char * param1, char *param2) {
> Inline_Stack_Vars;
> Inline_Stack_Reset;
> Inline_Stack_Push(sv_2mortal(newSVpv(param1, 0)));
> Inline_Stack_Push(sv_2mortal(newSVpv(param2, 0)));
> Inline_Stack_Done;
> perl_call_pv(static_callback, 0);
> Inline_Stack_Void;
> }
>