From: Junio C Hamano Date: Thu, 18 Aug 2011 00:17:16 +0000 (-0700) Subject: Merge branch 'rc/histogram-diff' into HEAD X-Git-Tag: v1.7.7-rc1~26^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b14b969ab98d5dac835e57a2b6b9e9229b2e1c97;p=git.git Merge branch 'rc/histogram-diff' into HEAD * rc/histogram-diff: xdiff/xhistogram: drop need for additional variable xdiff/xhistogram: rely on xdl_trim_ends() xdiff/xhistogram: rework handling of recursed results xdiff: do away with xdl_mmfile_next() Make test number unique xdiff/xprepare: use a smaller sample size for histogram diff xdiff/xprepare: skip classification teach --histogram to diff t4033-diff-patience: factor out tests xdiff/xpatience: factor out fall-back-diff function xdiff/xprepare: refactor abort cleanups xdiff/xprepare: use memset() Conflicts: xdiff/xprepare.c --- b14b969ab98d5dac835e57a2b6b9e9229b2e1c97 diff --cc xdiff/xprepare.c index 05a8f01f3,620fc9a65..eba31ffae --- a/xdiff/xprepare.c +++ b/xdiff/xprepare.c @@@ -83,17 -80,8 +83,16 @@@ static int xdl_init_classifier(xdlclass xdl_cha_free(&cf->ncha); return -1; } - for (i = 0; i < cf->hsize; i++) - cf->rchash[i] = NULL; + memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *)); + cf->alloc = size; + if (!(cf->rcrecs = (xdlclass_t **) xdl_malloc(cf->alloc * sizeof(xdlclass_t *)))) { + + xdl_free(cf->rchash); + xdl_cha_free(&cf->ncha); + return -1; + } + cf->count = 0; return 0; @@@ -158,10 -132,10 +157,10 @@@ static int xdl_classify_record(unsigne } -static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp, +static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_t const *xpp, xdlclassifier_t *cf, xdfile_t *xdf) { unsigned int hbits; - long i, nrec, hsize, bsize; + long nrec, hsize, bsize; unsigned long hav; char const *blk, *cur, *top, *prev; xrecord_t *crec; @@@ -225,13 -184,9 +209,9 @@@ crec->ha = hav; recs[nrec++] = crec; - if (xdl_classify_record(pass, cf, rhash, hbits, crec) < 0) { - - xdl_free(rhash); - xdl_free(recs); - xdl_cha_free(&xdf->rcha); - return -1; - } + if (!(xpp->flags & XDF_HISTOGRAM_DIFF) && - xdl_classify_record(cf, rhash, hbits, crec) < 0) ++ xdl_classify_record(pass, cf, rhash, hbits, crec) < 0) + goto abort; } } @@@ -313,16 -269,18 +294,18 @@@ int xdl_prepare_env(mmfile_t *mf1, mmfi return -1; } - if (!(xpp->flags & XDF_HISTOGRAM_DIFF)) - xdl_free_classifier(&cf); - if (!(xpp->flags & XDF_PATIENCE_DIFF) && + !(xpp->flags & XDF_HISTOGRAM_DIFF) && - xdl_optimize_ctxs(&xe->xdf1, &xe->xdf2) < 0) { + xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) { xdl_free_ctx(&xe->xdf2); xdl_free_ctx(&xe->xdf1); return -1; } - xdl_free_classifier(&cf); ++ if (!(xpp->flags & XDF_HISTOGRAM_DIFF)) ++ xdl_free_classifier(&cf); + return 0; }