Branch Coverage

deps/libgit2/src/libgit2/xdiff/xprepare.c
Criterion Covered Total %
branch 84 126 66.6


line true false branch
77 0 73 if (xdl_cha_init(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) {
81 0 73 if (!(cf->rchash = (xdlclass_t **) xdl_malloc(cf->hsize * sizeof(xdlclass_t *)))) {
89 0 73 if (!(cf->rcrecs = (xdlclass_t **) xdl_malloc(cf->alloc * sizeof(xdlclass_t *)))) {
119 39 137 for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
125 137 26 if (!rcrec) {
126 0 137 if (!(rcrec = xdl_cha_alloc(&cf->ncha))) {
131 0 137 if (cf->count > cf->alloc) {
133 0 0 if (!(rcrecs = (xdlclass_t **) xdl_realloc(cf->rcrecs, cf->alloc * sizeof(xdlclass_t *)))) {
148 66 97 (pass == 1) ? rcrec->len1++ : rcrec->len2++;
179 0 146 if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0)
181 0 146 if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *))))
186 0 146 if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
191 146 0 if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
192 163 146 for (top = blk + bsize; cur < top; ) {
195 0 163 if (nrec >= narec) {
197 0 0 if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *))))
201 0 163 if (!(crec = xdl_cha_alloc(&xdf->rcha)))
207 0 163 if (xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
212 0 146 if (!(rchg = (char *) xdl_malloc((nrec + 2) * sizeof(char))))
216 146 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
146 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
218 0 146 if (!(rindex = xdl_malloc((nrec + 1) * sizeof(*rindex))))
220 0 146 if (!(ha = xdl_malloc((nrec + 1) * sizeof(*ha))))
273 0 73 sample = (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF
279 0 73 if (xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
282 0 73 if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {
287 0 73 if (xdl_prepare_ctx(2, mf2, enl2, xpp, &cf, &xe->xdf2) < 0) {
294 73 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
73 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
295 0 73 (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
327 0 3 if (i - s > XDL_SIMSCAN_WINDOW)
329 0 3 if (e - i > XDL_SIMSCAN_WINDOW)
338 4 3 for (r = 1, rdis0 = 0, rpdis0 = 1; (i - r) >= s; r++) {
339 3 1 if (!dis[i - r])
341 1 0 else if (dis[i - r] == 2)
352 1 2 if (rdis0 == 0)
354 4 2 for (r = 1, rdis1 = 0, rpdis1 = 1; (i + r) <= e; r++) {
355 3 1 if (!dis[i + r])
357 1 0 else if (dis[i + r] == 2)
366 0 2 if (rdis1 == 0)
386 0 73 if (!(dis = (char *) xdl_malloc(xdf1->nrec + xdf2->nrec + 2))) {
394 0 73 if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT)
396 51 73 for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) {
398 51 0 nm = rcrec ? rcrec->len2 : 0;
399 6 45 dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
1 5 dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
402 0 73 if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT)
404 82 73 for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) {
406 82 0 nm = rcrec ? rcrec->len1 : 0;
407 2 80 dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
2 0 dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
410 51 73 for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart];
412 46 5 if (dis1[i] == 1 ||
1 45 if (dis1[i] == 1 ||
413 1 0 (dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) {
422 82 73 for (nreff = 0, i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart];
424 82 0 if (dis2[i] == 1 ||
2 80 if (dis2[i] == 1 ||
425 2 0 (dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) {
449 53 29 for (i = 0, lim = XDL_MIN(xdf1->nrec, xdf2->nrec); i < lim;
451 44 9 if ((*recs1)->ha != (*recs2)->ha)
458 50 29 for (lim -= i, i = 0; i < lim; i++, recs1--, recs2--)
459 44 6 if ((*recs1)->ha != (*recs2)->ha)