> -----Original Message-----
> From: Ken Williams [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 01, 2004 4:47 PM
> To: 00056312
> Cc: [EMAIL PROTECTED]
> Subject: Re: Array problems 
> 
> That should be array_pass(3, [EMAIL PROTECTED]).
> 
> Or you should just get the array size using av_len().

After I wrote this I tried it out, and there seems to be something wrong
with array-ref argument passing.  Observe the following test script:

------------------------------------------------
use Inline C;

@inputArray = ( "134.3", "2.224", "3.343");
array_pass([EMAIL PROTECTED]);

__END__
__C__

int array_pass (SV* array_ref) {
  AV  *av_ptr;
  int n;

  if ( !SvROK(array_ref) || SvTYPE(SvRV(array_ref)) != SVt_PVAV )
    croak("Argument must be array reference");

  av_ptr = (AV*) SvRV(array_ref);
  printf("Number of elements: %d\n", 1+sv_len(av_ptr));
}
------------------------------------------------

The output, using Inline 0.44 and perl 5.6.1, is:

  Number of elements: 1

which is wrong.  A similar experiment in XS seems to work fine.

 -Ken

Reply via email to