On Tue, Sep 23, 2003 at 01:14:54PM -0700, Ovid wrote:
> Hi all,
> 
> For the life of me, I can't figure out how I am segfaulting.  The following is a 
> minimal test
> case.  I think something's not getting initialized and thus causing some problem 
> with memory, but
> I can't tell what it is.
> 
> Output from the command line resembles:
> 
>   Index = 0.  String is 1.  Value = 1.000000
>   Segmentation fault
>

The problem seems to be that looks_like_number is expecting
a SV* but you are passing a char*. Not really sure why
char* works some time. If you clean out your _Inline
directory and run the script perl -MInline=NOISY script.pl
then you will see the compiler warnings that indicate you
are passing the wrong type.


>         for (i = 0; i < length; i++) {
>             SV *elem, **tmp = av_fetch(array, i, 0);
>             
>             if (!tmp)
>                 croak("Error fetching array index %i", i);
>             elem = *tmp;
>             string = SvPV(elem, PL_na);
>             if (looks_like_number(string)) {

              if (looks_like_number(elem)) {


              
>                 value = atof(string);
>                 printf("Index = %d.  String is %s.  Value = %f\n", i, string, value);
>             }
>             else {
>                 printf("%s does not look like a number\n");
>             }
>         }

-- 
The customer can count on us to authoritatively revolutionize prospective 
information to exceed customer expectations

Reply via email to