summaryrefslogtreecommitdiff
path: root/range-diff.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-09-18 10:07:02 -0700
committerJunio C Hamano <gitster@pobox.com>2025-09-18 10:07:02 -0700
commit7b776bc308f904850f36a82e19f9775e672d464c (patch)
tree90f0638597e3c9be9360f3b35f5ac986dd9e7fa2 /range-diff.h
parent44c0d062bd2fed84ba1ac930a153de37a5280cd3 (diff)
parent00727249ec8404c68391ec58e9c9f0d8a88d5ca0 (diff)
Merge branch 'pc/range-diff-memory-limit'
"git range-diff" learned a way to limit the memory consumed by O(N*N) cost matrix. * pc/range-diff-memory-limit: range-diff: add configurable memory limit for cost matrix
Diffstat (limited to 'range-diff.h')
-rw-r--r--range-diff.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/range-diff.h b/range-diff.h
index cd85000b5a..9d39818e34 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -5,6 +5,10 @@
#include "strvec.h"
#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
+#define RANGE_DIFF_MAX_MEMORY_DEFAULT \
+ (sizeof(void*) >= 8 ? \
+ ((size_t)(1024L * 1024L) * (size_t)(4L * 1024L)) : /* 4GB on 64-bit */ \
+ ((size_t)(1024L * 1024L) * (size_t)(2L * 1024L))) /* 2GB on 32-bit */
/*
* A much higher value than the default, when we KNOW we are comparing
@@ -17,6 +21,7 @@ struct range_diff_options {
unsigned dual_color:1;
unsigned left_only:1, right_only:1;
unsigned include_merges:1;
+ size_t max_memory;
const struct diff_options *diffopt; /* may be NULL */
const struct strvec *other_arg; /* may be NULL */
};