in reply to Re: LoA from XS
in thread LoA from XS

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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^3: LoA from XS
by almut (Canon) on Apr 21, 2009 at 00:52 UTC

    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*)