X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=delta.h;h=09b2e1eed5dfc772feb38715f051eff43570d4cb;hb=ac4c758adcf52b913b82d481626b0f8648e95475;hp=31d1820f80f2887d51808170fc86585ada42d42e;hpb=302ebfe52192fff9a2c1c612dff22325fd073acc;p=git.git diff --git a/delta.h b/delta.h index 31d1820f..09b2e1ee 100644 --- a/delta.h +++ b/delta.h @@ -2,11 +2,11 @@ #define DELTA_H /* handling of delta buffers */ -extern void *diff_delta(void *from_buf, unsigned long from_size, - void *to_buf, unsigned long to_size, +extern void *diff_delta(const void *from_buf, unsigned long from_size, + const void *to_buf, unsigned long to_size, unsigned long *delta_size, unsigned long max_size); extern void *patch_delta(void *src_buf, unsigned long src_size, - void *delta_buf, unsigned long delta_size, + const void *delta_buf, unsigned long delta_size, unsigned long *dst_size); /* the smallest possible delta size is 4 bytes */ @@ -16,17 +16,18 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, * This must be called twice on the delta data buffer, first to get the * expected reference buffer size, and again to get the result buffer size. */ -static inline unsigned long get_delta_hdr_size(const unsigned char **datap) +static inline unsigned long get_delta_hdr_size(const unsigned char **datap, + const unsigned char *top) { const unsigned char *data = *datap; - unsigned char cmd = *data++; - unsigned long size = cmd & ~0x80; - int i = 7; - while (cmd & 0x80) { + unsigned char cmd; + unsigned long size = 0; + int i = 0; + do { cmd = *data++; size |= (cmd & ~0x80) << i; i += 7; - } + } while (cmd & 0x80 && data < top); *datap = data; return size; }