in reply to Re^3: Passing integer pointer in XS? (OUTPUT:)
in thread Passing integer pointer in XS?
Problem: You can't write to protocol or model safely because one of the force functions wasn't used. You might end up changing variables and constants you didn't mean to change. (They might have fixed that in 5.24?)
use strict; use warnings; use feature qw( say ); use Inline C => <<'__EOS__'; void testing(char* s) { s[0] = 'y'; } __EOS__ my $x = "x"; my $y = $x; say "$x-$y"; testing($y); say "$x-$y";
orx-x y-y <-- Changed both $x and $y
for (1..2) { my $y = "x"; say $y; testing($y); }
x y <-- Changed the constant!
Note: The caller will need to do s/\0.*// for $protocol, $model;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Passing integer pointer in XS? (const)
by tye (Sage) on Jul 18, 2016 at 21:51 UTC | |
by ikegami (Patriarch) on Jul 18, 2016 at 21:54 UTC |
In Section
Seekers of Perl Wisdom