in reply to Re^2: Is this a sane/safe way to pass an aref into a C function? (XS<Perl)
in thread Is this a sane/safe way to pass an aref into a C function?
PS: I think your check() would be more "C like" coded something like this:
The variable: int i is unnecessary. With the C calling convention on 32 bit machine, check() is passed a 32 bit pointer to n (pointer to an array of unsigned bytes) and a 32 bit signed integer, len on the stack. These are copies for the subroutine to modify and use as it wishes.void check(unsigned char* n, int len) { while (len--) { printf ("%d\n", *n++); } }
This n[i] syntax is often coded by the compiler as (n i*size_of_n) plus base address. Whereas n++ is coded as n plus the size_of_n.
|
|---|