git-commit-vandalism/xdiff
Stefan Beller 64c4e8bccd xdiff/xhistogram: move index allocation into find_lcs
This fixes a memory issue when recursing a lot, which can be reproduced as

    seq 1   100000 >one
    seq 1 4 100000 >two
    git diff --no-index --histogram one two

Before this patch, histogram_diff would call itself recursively before
calling free_index, which would mean a lot of memory is allocated during
the recursion and only freed afterwards. By moving the memory allocation
(and its free call) into find_lcs, the memory is free'd before we recurse,
such that memory is reused in the next step of the recursion instead of
using new memory.

This addresses only the memory pressure, not the run time complexity,
that is also awful for the corner case outlined above.

Helpful in understanding the code (in addition to the sparse history of
this file), was https://stackoverflow.com/a/32367597 which reproduces
most of the code comments of the JGit implementation.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-07-19 12:46:03 -07:00
..
xdiff.h Merge branch 'jk/diff-compact-heuristic' 2016-05-06 14:45:46 -07:00
xdiffi.c xdiff: implement empty line chunk heuristic 2016-04-19 10:53:34 -07:00
xdiffi.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xemit.c Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context' into maint 2016-09-29 16:49:39 -07:00
xemit.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xhistogram.c xdiff/xhistogram: move index allocation into find_lcs 2018-07-19 12:46:03 -07:00
xinclude.h
xmacros.h
xmerge.c Merge branch 'ps/plug-xdl-merge-leak' 2016-02-26 13:37:22 -08:00
xpatience.c diff: fix a double off-by-one with --ignore-space-at-eol 2016-07-11 11:55:53 -07:00
xprepare.c xdiff/xprepare: fix a memory leak 2016-03-04 15:51:08 -08:00
xprepare.h
xtypes.h
xutils.c diff: fix a double off-by-one with --ignore-space-at-eol 2016-07-11 11:55:53 -07:00
xutils.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00