X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=delta.h;h=a15350dabcd497d4cb21261721706eca072de034;hb=692c7fc9cb81a2f68b23199d5b8612494fe4d317;hp=bc3a220179cefd0af169ab4f2e6aeeb5675f900a;hpb=85c1f337be49eaa9a22e42a1c9958deef5ab57c3;p=git.git diff --git a/delta.h b/delta.h index bc3a2201..a15350da 100644 --- a/delta.h +++ b/delta.h @@ -9,4 +9,26 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, void *delta_buf, unsigned long delta_size, unsigned long *dst_size); +/* the smallest possible delta size is 4 bytes */ +#define DELTA_SIZE_MIN 4 + +/* + * 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) +{ + const unsigned char *data = *datap; + unsigned char cmd; + unsigned long size = 0; + int i = 0; + do { + cmd = *data++; + size |= (cmd & ~0x80) << i; + i += 7; + } while (cmd & 0x80); + *datap = data; + return size; +} + #endif