X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=diff-delta.c;h=b2ae7b5e6c3b4aa409ccfa60f67d5c8eb1690504;hb=bd321bcc51e95f644ac5335abe673afcbcaade62;hp=fd9b37f4910e95faac206339e23b05312ba3a52d;hpb=85c1f337be49eaa9a22e42a1c9958deef5ab57c3;p=git.git diff --git a/diff-delta.c b/diff-delta.c index fd9b37f4..b2ae7b5e 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -228,28 +228,22 @@ void *diff_delta(void *from_buf, unsigned long from_size, top = to_buf + to_size; /* store reference buffer size */ - orig = out + outpos++; - *orig = i = 0; - do { - if (from_size & 0xff) { - *orig |= (1 << i); - out[outpos++] = from_size; - } - i++; - from_size >>= 8; - } while (from_size); + out[outpos++] = from_size; + from_size >>= 7; + while (from_size) { + out[outpos - 1] |= 0x80; + out[outpos++] = from_size; + from_size >>= 7; + } /* store target buffer size */ - orig = out + outpos++; - *orig = i = 0; - do { - if (to_size & 0xff) { - *orig |= (1 << i); - out[outpos++] = to_size; - } - i++; - to_size >>= 8; - } while (to_size); + out[outpos++] = to_size; + to_size >>= 7; + while (to_size) { + out[outpos - 1] |= 0x80; + out[outpos++] = to_size; + to_size >>= 7; + } inscnt = 0; moff = 0; @@ -312,12 +306,13 @@ void *diff_delta(void *from_buf, unsigned long from_size, *orig = i; } - /* next time around the largest possible output is 1 + 4 + 3 */ if (max_size && outpos > max_size) { free(out); delta_cleanup(&bdf); return NULL; } + + /* next time around the largest possible output is 1 + 4 + 3 */ if (outpos > outsize - 8) { void *tmp = out; outsize = outsize * 3 / 2;