in reply to Passing a bytestring from Perl to Inline::C as a 2d array
You cannot cast a 1D array of integers (as produced by pack), to a 2D array of pointers to arrays of integers. You need to do the index calculations yourself (untested):
void c_function( char *bytes, int rows, int cols ) { int *table = (int *)bytes; int i, j; for ( j = 0; j < cols, ++j ) { for ( i = 0; j < rows; ++i ) { ++table[ j * rows + i ]; } } }
Also, please use <code> ... </code> tags not <pre> ... </pre> tags
|
|---|