[mplspm]: Deference a hash reference _twice_ in *.xs??

Ken Williams ken at mathforum.org
Mon Mar 11 15:15:43 CST 2002


Mark,

I'm far from adept at XS, but what happens if you turn 'hashref' to 
'*hashref' on line 9?



On Monday, March 11, 2002, at 03:03 PM, Mark Conty wrote:
> ... and here's a simplified fragment of the C code:
>
>     1   SV*
>     2   showHash(hashref)
>     3   	SV	*hashref
>     4       CODE:
>     5   	HV	*hash;
>     6   	I32	count;
>     7   {
>     8   	if ( ! SvROK(hashref) ||
>     9   		SvTYPE((hash=(HV*)SvRV(SvRV(hashref)))) != SVt_PVHV )
>    10   	    croak("Parameter is not a reference to a hash -- type is 
> %d.\n",
>    11   		SvTYPE(hash));

[...]

> What I'm puzzled by is at line 9.  If I don't doubly-dereference 
> hashref,
> the resulting SvTYPE() value is 3, which means it's a reference.  Duhh, 
> of
> course it's a reference!  Sheesh...  Tried using only one SvRV() and 
> casting
> (HV*) inside, but that didn't make any difference.


  -Ken



--------------------------------------------------
Minneapolis Perl Mongers mailing list

To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.



More information about the Mpls-pm mailing list