Branch Coverage

deps/libgit2/src/xdiff/xprepare.c
Criterion Covered Total %
branch 82 122 67.2


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 *))))
184 0 146 if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
189 0 146 if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
195 146 0 if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
196 163 146 for (top = blk + bsize; cur < top; ) {
199 0 163 if (nrec >= narec) {
201 0 0 if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *))))
205 0 163 if (!(crec = xdl_cha_alloc(&xdf->rcha)))
218 0 146 if (!(rchg = (char *) xdl_malloc((nrec + 2) * sizeof(char))))
222 0 146 if (!(rindex = (long *) xdl_malloc((nrec + 1) * sizeof(long))))
224 0 146 if (!(ha = (unsigned long *) xdl_malloc((nrec + 1) * sizeof(unsigned long))))
276 0 73 sample = (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF
286 0 73 if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {
291 0 73 if (xdl_prepare_ctx(2, mf2, enl2, xpp, &cf, &xe->xdf2) < 0) {
298 73 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
73 0 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
299 0 73 (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
308 73 0 if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)
332 0 3 if (i - s > XDL_SIMSCAN_WINDOW)
334 0 3 if (e - i > XDL_SIMSCAN_WINDOW)
343 4 3 for (r = 1, rdis0 = 0, rpdis0 = 1; (i - r) >= s; r++) {
344 3 1 if (!dis[i - r])
346 1 0 else if (dis[i - r] == 2)
357 1 2 if (rdis0 == 0)
359 4 2 for (r = 1, rdis1 = 0, rpdis1 = 1; (i + r) <= e; r++) {
360 3 1 if (!dis[i + r])
362 1 0 else if (dis[i + r] == 2)
371 0 2 if (rdis1 == 0)
391 0 73 if (!(dis = (char *) xdl_malloc(xdf1->nrec + xdf2->nrec + 2))) {
399 0 73 if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT)
401 51 73 for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) {
403 51 0 nm = rcrec ? rcrec->len2 : 0;
404 6 45 dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
1 5 dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
407 0 73 if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT)
409 82 73 for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) {
411 82 0 nm = rcrec ? rcrec->len1 : 0;
412 2 80 dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
2 0 dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
415 51 73 for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart];
417 46 5 if (dis1[i] == 1 ||
1 45 if (dis1[i] == 1 ||
418 1 0 (dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) {
427 82 73 for (nreff = 0, i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart];
429 82 0 if (dis2[i] == 1 ||
2 80 if (dis2[i] == 1 ||
430 2 0 (dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) {
454 53 29 for (i = 0, lim = XDL_MIN(xdf1->nrec, xdf2->nrec); i < lim;
456 44 9 if ((*recs1)->ha != (*recs2)->ha)
463 50 29 for (lim -= i, i = 0; i < lim; i++, recs1--, recs2--)
464 44 6 if ((*recs1)->ha != (*recs2)->ha)