16
23
* using free_delta_index().
18
25
extern struct delta_index *
19
create_delta_index(const void *buf, unsigned long bufsize,
20
unsigned long agg_src_offset);
26
create_delta_index(const struct source_info *src);
23
29
* free_delta_index: free the index created by create_delta_index()
47
53
create_delta(struct delta_index **indexes,
48
unsigned int num_indexes,
49
const void *buf, unsigned long bufsize,
50
unsigned long *delta_size, unsigned long max_delta_size);
53
* diff_delta: create a delta from source buffer to target buffer
55
* If max_delta_size is non-zero and the resulting delta is to be larger
56
* than max_delta_size then NULL is returned. On success, a non-NULL
57
* pointer to the buffer with the delta data is returned and *delta_size is
58
* updated with its size. The returned buffer must be freed by the caller.
61
diff_delta(const void *src_buf, unsigned long src_bufsize,
62
const void *trg_buf, unsigned long trg_bufsize,
63
unsigned long *delta_size, unsigned long max_delta_size)
65
struct delta_index *index = create_delta_index(src_buf, src_bufsize, 0);
67
void *delta = create_delta(&index, 1, trg_buf, trg_bufsize,
68
delta_size, max_delta_size);
69
free_delta_index(index);
76
* patch_delta: recreate target buffer given source buffer and delta data
78
* On success, a non-NULL pointer to the target buffer is returned and
79
* *trg_bufsize is updated with its size. On failure a NULL pointer is
80
* returned. The returned buffer must be freed by the caller.
82
extern void *patch_delta(const void *src_buf, unsigned long src_size,
83
const void *delta_buf, unsigned long delta_size,
84
unsigned long *dst_size);
54
unsigned int num_indexes,
55
const void *buf, unsigned long bufsize,
56
unsigned long *delta_size, unsigned long max_delta_size);
86
58
/* the smallest possible delta size is 4 bytes */
87
#define DELTA_SIZE_MIN 4
59
#define DELTA_SIZE_MIN 4
90
62
* This must be called twice on the delta data buffer, first to get the
91
63
* expected source buffer size, and again to get the target buffer size.
93
65
static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
94
const unsigned char *top)
66
const unsigned char *top)
96
68
const unsigned char *data = *datap;