OlegG has asked for the wisdom of the Perl Monks concerning the following question:
XS:my ($num, $str); sub_from_xs(\$num, \$str);
Is this code correct? How to assign new values to passed references properly?void sub_from_xs(SV *num, SV *str) INIT: if ((!SvROK(num))) croak("not a reference"); if ((!SvROK(str))) croak("not a reference"); int nx; char *sx; CODE: nx = get_nx(); sv_setiv_mg(SvRV(num), nx); sx = get_sx(); sv_setpv_mg(SvRV(str), sx);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XSUB: pass scalar by reference and assign value
by ikegami (Patriarch) on Jun 13, 2011 at 20:54 UTC | |
by OlegG (Monk) on Jun 14, 2011 at 03:43 UTC | |
|
Re: XSUB: pass scalar by reference and assign value
by ikegami (Patriarch) on Jun 14, 2011 at 04:11 UTC |