Re: [PATCH] Find size of SHA1 object without inflating everything.
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Jun 2, 2005, 22:10 UTC
- Message-ID
- <Pine.LNX.4.58.0506021508020.1876@ppc970.osdl.org>
- In-Reply-To
- <7vwtpc60z3.fsf_-_@assigned-by-dhcp.cox.net>
On Thu, 2 Jun 2005, Junio C Hamano wrote:
> > +int sha1_file_size(const unsigned char *sha1, unsigned long *sizep)
...
> + ret = unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr));
...
> + delta_data_head = unpack_sha1_rest(&stream, hdr, 200);
Why do you do this? You've already unpacked 1024 bytes (including the header), now you want to unpack at least 200 bytes past the header (which is less than what you already did.
So here "unpack_sha1_rest()" just ends up being a "xmalloc + memcpy", but since you don't actually want the malloc (indeed, you're leaking it, as far as I can tell), it seems to be all bad..
Linus