Re: Returning an array reference or nothing

[email protected] (Torsten Schoenfeld)
Newsgroups perl.xs
Message-ID <[email protected]>
On 07.06.2010 10:43, Florian Weimer wrote:
> Is the following the correct code sequence to return an array
> reference or nothing (if result is 0) from an XS function?
>
>         PPCODE:
>           AV *result = 0;
>           if (some_condition) {
>               result = newAV();
>               av_push(result, some_value);
>           }
>           if (result) {
>               EXTEND(SP, 1);
>               PUSHs(newRV_inc((SV*)result));
>           }
>
> It's not mentioned in perlxs, but some CPAN modules seem to use this.

Looks correct, yes.  And it does appear in `perldoc perlxs'; look under 
"Returning Undef And Empty Lists".
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.