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( int channel, char* buf, int len ) {
- tye
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is this a sane/safe way to pass an aref into a C function? (XS<Perl)
by stevieb (Canon) on Jan 22, 2017 at 18:15 UTC | |
by Marshall (Canon) on Jan 23, 2017 at 03:44 UTC |
In Section
Seekers of Perl Wisdom