* Convert subscript list into linear element number (from 0) * * We assume caller has already range-checked the dimensions and subscripts, * so no overflow is possible. */
| 29 | * so no overflow is possible. |
| 30 | */ |
| 31 | int |
| 32 | ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx) |
| 33 | { |
| 34 | int i, |
| 35 | scale = 1, |
| 36 | offset = 0; |
| 37 | |
| 38 | for (i = n - 1; i >= 0; i--) |
| 39 | { |
| 40 | offset += (indx[i] - lb[i]) * scale; |
| 41 | scale *= dim[i]; |
| 42 | } |
| 43 | return offset; |
| 44 | } |
| 45 | |
| 46 | /* |
| 47 | * Same, but subscripts are assumed 0-based, and use a scale array |
no outgoing calls
no test coverage detected