in reply to LoA from XS

Shouldn't that be for( j = 0; j < av_len( av ); ++j ) { ?

Replies are listed 'Best First'.
Re^2: LoA from XS
by ikegami (Patriarch) on Apr 21, 2009 at 00:36 UTC
    No.

    Returns the highest index in the array. The number of elements in the array is av_len(av) + 1 . Returns -1 if the array is empty

Re^2: LoA from XS
by BrowserUk (Patriarch) on Apr 21, 2009 at 00:41 UTC

    No. According to the docs:

    av_len Returns the highest index in the array.

    It's basically the equivalent of Perl's $#{ aref }, hence the unusual condition. I think if I could pursuade it to start at the right place, it would stop correctly too. I just cannot see why it doesn't?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Then, you shouldn't printf( "Item %d has %d elements\n", i, av_len( av ) );, if it has in fact av_len(av)+1 (i.e. 10). :)

      Anyhow, I think the problem is with reading the string out of sv2 — at least I don't get any sensible values here at all, like 'A'..'J' (only random junk out of memory instead).  I'll take a closer look ... well, no longer required, syphilis has already done so (—> av_fetch is returning an SV**, not SV*)