in reply to Extending Perl with C: how to use an array reference?

Not certain if it'd be faster, and you might consider it uglier, but...

Have you considered just using pack() in Perl to turn the Perl array into an int[], then passing the resulting binary scalar into your XS, grabbing the SvPV off the scalar, and treating it like an int[] ? That leaves most of the heavy lifting to Perl.

BTW: In your version, I fear you've got a memory leak unless foo_in_c() free()'s your temp array...


Perl Contrarian & SQL fanboy
  • Comment on Re: Extending Perl with C: how to use an array reference?