in reply to XS returning undef?

What did you expect my $hashref to be?
I assume 'RETVAL', which is what it should be (in scalar context).

What is RETVAL supposed to be?
If you wanted 'dirinfo', try list context.
If you don't understand why that happened, read "List" is a Four-Letter Word.

update: I see, try increasing the ref count(newRV_inc).


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: XS returning undef?
by meetraz (Hermit) on Mar 09, 2003 at 07:44 UTC
    I'm setting dirinfo to a hashref in this line:

    dirinfo = newRV_noinc((SV *)newdirinfo);

    And since dirinfo is listed in the OUTPUT section, I'm expecting my $hashref to actually be the hashref I created in the newRV_noinc() call. In the C code generated by xsubpp, it looks ok:

    ST(1) = dirinfo; SvSETMAGIC(ST(1));

    so obviously the second item on the stack (my $hashref) is getting set to dirinfo as it should. The only thing I can think of is that it's somehow being garabage collected too soon.

    RETVAL is an integer status code that I'm returning.

    Update: I checked on RETVAL ($result in my code example above) and it's getting set properly.