int cb2mllr_read(const char *fn, int32 ** out_cb2mllr, int32 * out_n_cb, int32 * out_n_mllr) { int ret, i, n_d, n_r; int *did_map; int32 *cb2mllr; int in_hole = FALSE; int beg_hole = 0; ret = s3map_read(fn, (void **) out_cb2mllr, out_n_cb, out_n_mllr, sizeof(int32)); if (ret == S3_SUCCESS) { n_d = *out_n_cb; n_r = *out_n_mllr; cb2mllr = *out_cb2mllr; did_map = ckd_calloc(n_r, sizeof(int)); for (i = 0; i < n_d; i++) { if (cb2mllr[i] >= (int32) * out_n_mllr) { E_FATAL ("%s cb2mllr[%d] -> %d which is >= n_mllr_class (%d)\n", fn, i, cb2mllr[i], *out_n_mllr); } else if (cb2mllr[i] >= 0) did_map[cb2mllr[i]] = IS_MAPPED; } for (i = 0; i < n_d; i++) { if (cb2mllr[i] < 0) continue; /* skipped */ if (!in_hole && (did_map[cb2mllr[i]] == NOT_MAPPED)) { beg_hole = i; in_hole = TRUE; } if (in_hole && (did_map[cb2mllr[i]] == IS_MAPPED)) { E_FATAL("cb unmapped in region [%u %u]\n", beg_hole, i - 1); in_hole = FALSE; } } if (in_hole) { E_FATAL("cb unmapped in region [%u %u]\n", beg_hole, i - 1); } ckd_free(did_map); } return ret; }
int s3ts2cb_read(const char *fn, uint32 **out_ts2cb, uint32 *out_n_ts, uint32 *out_n_cb) { int ret, i, n_d, n_r; int *did_map, incomplete; uint32 *ts2cb; ret = s3map_read(fn, (void **)out_ts2cb, out_n_ts, out_n_cb, sizeof(uint32)); if (ret == S3_SUCCESS) { n_d = *out_n_ts; n_r = *out_n_cb; ts2cb = *out_ts2cb; did_map = ckd_calloc(n_r, sizeof(int)); for (i = 0; i < n_d; i++) { did_map[ts2cb[i]] = TRUE; } for (i = 0, incomplete = FALSE; i < n_r; i++) { if (!did_map[i]) incomplete = TRUE; } if (incomplete) { E_WARN("%s maps into [0..%u] rather than onto it\n", fn, n_r-1); } ckd_free(did_map); } return ret; }