X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=delta.h;h=a15350dabcd497d4cb21261721706eca072de034;hb=b992933853ccffac85f7e40310167ef7b8f0432e;hp=c6a476353f7122884cb4769685089d63c886631c;hpb=962537a3eb03a118cf27d9d0da365a3216ed1caa;p=git.git diff --git a/delta.h b/delta.h index c6a47635..a15350da 100644 --- a/delta.h +++ b/delta.h @@ -9,8 +9,8 @@ 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 2 bytes (empty to empty) */ -#define DELTA_SIZE_MIN 2 +/* 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 @@ -19,14 +19,14 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, static inline unsigned long get_delta_hdr_size(const unsigned char **datap) { 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); *datap = data; return size; }