forked from artagnon/phoenixfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelta.h
43 lines (34 loc) · 969 Bytes
/
delta.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef DELTA_H_
#define DELTA_H_
#include "common.h"
#define HASH_LIMIT 64
#define RABIN_SHIFT 23
#define RABIN_WINDOW 16
#define DELTA_SIZE_MIN 4
/*
* The maximum size for any opcode sequence, including the initial header
* plus Rabin window plus biggest copy.
*/
#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
struct index_entry {
const unsigned char *ptr;
unsigned int val;
};
struct unpacked_index_entry {
struct index_entry entry;
struct unpacked_index_entry *next;
};
struct delta_index {
unsigned long memsize;
const void *src_buf;
unsigned long src_size;
unsigned int hash_mask;
struct index_entry *hash[0];
};
void *diff_delta(const void *src_buf, unsigned long src_bufsize,
const void *trg_buf, unsigned long trg_bufsize,
unsigned long *delta_size, unsigned long max_delta_size);
void *patch_delta(const void *src_buf, unsigned long src_size,
const void *delta_buf, unsigned long delta_size,
unsigned long *dst_size);
#endif