From: Junio C Hamano Date: Fri, 05 May 2006 17:38:46 GMT Subject: Re: [PATCH] binary patch. Message-ID: <7vejz8z80p.fsf@assigned-by-dhcp.cox.net> In-Reply-To: Nicolas Pitre writes: >> + delta = NULL; >> + deflated = deflate_it(two->ptr, two->size, &deflate_size); >> + if (one->size && two->size) { >> + delta = diff_delta(one->ptr, one->size, >> + two->ptr, two->size, >> + &delta_size, deflate_size); > > Here you probably want to use deflate_size-1 (deflate_size can't be 0). I am not sure if -1 is worth here. The delta is going to be deflated and hopefully gets a bit smaller, so if we really care that level of detail, it might be worth to do (deflate_size*3/2) or something like that here, use delta with or without deflate whichever is smaller, and mark the uncompressed delta with a different tag ("uncompressed delta"?). And for symmetry, to deal with uncompressible data, we may want to have "uncompressed literal" as well. >> + orig_size = delta_size; >> + if (delta) >> + delta = deflate_it(delta, delta_size, &delta_size); > > Here you're leaking the original delta buffer memory. Indeed. Thanks.