1#include "cache.h"
2#include "diff.h"
3#include "diffcore.h"
4#include "delta.h"
5#include "count-delta.h"
6
7static int diffcore_count_changes_1(void *src, unsigned long src_size,
8 void *dst, unsigned long dst_size,
9 unsigned long delta_limit,
10 unsigned long *src_copied,
11 unsigned long *literal_added)
12{
13 void *delta;
14 unsigned long delta_size;
15
16 delta = diff_delta(src, src_size,
17 dst, dst_size,
18 &delta_size, delta_limit);
19 if (!delta)
20 /* If delta_limit is exceeded, we have too much differences */
21 return -1;
22
23 /* Estimate the edit size by interpreting delta. */
24 if (count_delta(delta, delta_size, src_copied, literal_added)) {
25 free(delta);
26 return -1;
27 }
28 free(delta);
29 return 0;
30}
31
32int diffcore_count_changes(void *src, unsigned long src_size,
33 void *dst, unsigned long dst_size,
34 unsigned long delta_limit,
35 unsigned long *src_copied,
36 unsigned long *literal_added)
37{
38 return diffcore_count_changes_1(src, src_size,
39 dst, dst_size,
40 delta_limit,
41 src_copied,
42 literal_added);
43}