http://qs1969.pair.com?node_id=1180124


in reply to Is this a sane/safe way to pass an aref into a C function?

XS code is much more likely to be buggy and fragile than Perl code. If you want to pass a list of bytes from Perl to C, then you would be better off doing it as a data structure that doesn't require your C code to try to deal with Perl data structures. This will also have the side-effect of you having less XS code, which will reduce how many bugs you have to fix and how long it will take you to fix the bugs you have.

So just use:

... my $str = pack "U0C*", @bytes; testing( $channel, $str, length($str) ); ... int testing( in­t channel, char* buf, int len ) {

- tye