Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^3: simple XSby almut (Canon) |
on Mar 01, 2010 at 08:01 UTC ( [id://825845]=note: print w/replies, xml ) | Need Help?? |
Taking a closer look, I think there are also other problems with your code. In particular, you're not (Perl-)dereferencing (SvRV()) the arrayref you get from hv_fetch() as the value associated with the hash entry "permutation". Also, you're not checking that the SV** pointer which hv_fetch() returns is non-null before (C-)dereferencing it... Somewhat simplified, the sequence of steps should look something like this (I'm using Inline::C here for ease of demo):
In real (production) code, you should also verify that you in fact have the appropriate types (using SvROK(), SvIOK(), etc.) before treating them as such. (As for chromatic's note below, the mapping of the Perl integer to the C int index is being taken care of by Inline::C in this example.)
In Section
Seekers of Perl Wisdom
|
|