| 292 | |
| 293 | |
| 294 | qcomp** cpu_allocAndInitMatrixWrapper(qcomp* arr, qindex dim) { |
| 295 | |
| 296 | // do not allocate if arr alloc failed (caller will handle) |
| 297 | if (arr == nullptr) |
| 298 | return nullptr; |
| 299 | |
| 300 | // allocate only the outer memory (i.e. one row's worth) |
| 301 | qcomp** out = (qcomp**) malloc(dim * sizeof *out); |
| 302 | |
| 303 | // caller will handle malloc failure |
| 304 | if (out == nullptr) |
| 305 | return out; |
| 306 | |
| 307 | // populate out with offsets of arr |
| 308 | for (qindex i=0; i<dim; i++) |
| 309 | out[i] = &arr[i*dim]; |
| 310 | |
| 311 | return out; // may be nullptr |
| 312 | } |
| 313 | |
| 314 | |
| 315 | void cpu_deallocMatrixWrapper(qcomp** wrapper) { |
no outgoing calls
no test coverage detected