summaryrefslogtreecommitdiff
path: root/diff-delta.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 02:30:20 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-26 02:30:20 (GMT)
commit75c42d8cc3b42e4b82946848b8ba902b4bbcc38d (patch)
treef123aa0c4a72ab09eef8cd420d9bcf5391343666 /diff-delta.c
parent78817c15de0dfb408d1e35a2f692f54dc51e80a3 (diff)
downloadgit-75c42d8cc3b42e4b82946848b8ba902b4bbcc38d.zip
git-75c42d8cc3b42e4b82946848b8ba902b4bbcc38d.tar.gz
git-75c42d8cc3b42e4b82946848b8ba902b4bbcc38d.tar.bz2
Add a "max_size" parameter to diff_delta()
Anything that generates a delta to see if two objects are close usually isn't interested in the delta ends up being bigger than some specified size, and this allows us to stop delta generation early when that happens.
Diffstat (limited to 'diff-delta.c')
-rw-r--r--diff-delta.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/diff-delta.c b/diff-delta.c
index 480f03c..fd9b37f 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -203,7 +203,8 @@ static void delta_cleanup(bdfile_t *bdf)
void *diff_delta(void *from_buf, unsigned long from_size,
void *to_buf, unsigned long to_size,
- unsigned long *delta_size)
+ unsigned long *delta_size,
+ unsigned long max_size)
{
int i, outpos, outsize, inscnt, csize, msize, moff;
unsigned int fp;
@@ -312,6 +313,11 @@ void *diff_delta(void *from_buf, unsigned long from_size,
}
/* next time around the largest possible output is 1 + 4 + 3 */
+ if (max_size && outpos > max_size) {
+ free(out);
+ delta_cleanup(&bdf);
+ return NULL;
+ }
if (outpos > outsize - 8) {
void *tmp = out;
outsize = outsize * 3 / 2;