Re: Returning an array reference or nothing

2010-06-07 Thread Torsten Schoenfeld
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

Returning an array reference or nothing

2010-06-07 Thread Florian Weimer
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

Re: Array reference

2008-10-26 Thread Jeffrey Ratcliffe
2008/10/26 Steve Fink <[EMAIL PROTECTED]>: > That part is good; you're dereferencing. The rest isn't, because you aren't. Thanks! Jeff

Re: Array reference

2008-10-26 Thread Steve Fink
> if (SvROK(array) && SvTYPE(SvRV(array)) == SVt_PVAV) > printf("array reference\n"); That part is good; you're dereferencing. The rest isn't, because you aren't. You want something like: void print_array(SV* array_sv) { ... if (! (SvROK(ar

Re: Array reference

2008-10-25 Thread Jeffrey Ratcliffe
2008/10/24 Nicholas Clark <[EMAIL PROTECTED]>: > Indeed, array reference, not array. So here: > >> vector_length = av_len(array) + 1; > > you need > > vector_length = av_len(SvRV(array)) + 1; Doh! Sometimes you just can't see the wood for the trees. Thanks! Jeff

Re: Array reference

2008-10-24 Thread Nicholas Clark
On Fri, Oct 24, 2008 at 09:03:42PM +0200, Jeffrey Ratcliffe wrote: > I seem to be having trouble with an array reference in my xs module. > I've hacked up a simple example using inline c: > > #!/usr/bin/perl > > use Inline C; > > my @array = ( 3, 2, 1 ); &

Array reference

2008-10-24 Thread Jeffrey Ratcliffe
I seem to be having trouble with an array reference in my xs module. I've hacked up a simple example using inline c: #!/usr/bin/perl use Inline C; my @array = ( 3, 2, 1 ); print_array([EMAIL PROTECTED]); __END__ __C__ void print_array(SV * array) { int i, vector_length = 0; SV ** svp;