I wrote:
:I wanted a fast count of the number of set (clear) bits in a string.
:I'm getting rather strange results, and I haven't found a clue in
:the docs or archives. Here's the code:
[...]
: char b_set[256];
: UV cset(char* pv, UV len) {
: UV s = 0;
: UV i = len >> 3; # len gives string length in bits
: while (i--) {
: s += (UV)b_set[*pv++];
Silly me - they're signed chars, so any byte over 0x7f is going to
point before the start of the array - no wonder I seemed to get
random results. :(
For what it's worth, 'unsigned char* pv' in the function signature
doesn't seem to be recognisable by Inline::C, even though such a
type does appear in the typemap. Perhaps there's a problem with
multi-word types? Or maybe I've just made another silly error ...
Hugo