From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH] Find size of SHA1 object without inflating everything. Date: Thu, 2 Jun 2005 15:10:11 -0700 (PDT) Message-ID: References: <7vy89ums2l.fsf@assigned-by-dhcp.cox.net> <7vis0xkjn4.fsf@assigned-by-dhcp.cox.net> <7v4qcg906f.fsf_-_@assigned-by-dhcp.cox.net> <7vwtpc60z3.fsf_-_@assigned-by-dhcp.cox.net> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Jun 03 00:08:01 2005 Return-path: Received: from vger.kernel.org ([12.107.209.244]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ddxpk-00011s-B7 for gcvg-git@gmane.org; Fri, 03 Jun 2005 00:06:36 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261432AbVFBWJM (ORCPT ); Thu, 2 Jun 2005 18:09:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261429AbVFBWJM (ORCPT ); Thu, 2 Jun 2005 18:09:12 -0400 Received: from fire.osdl.org ([65.172.181.4]:25532 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S261351AbVFBWIW (ORCPT ); Thu, 2 Jun 2005 18:08:22 -0400 Received: from shell0.pdx.osdl.net (fw.osdl.org [65.172.181.6]) by smtp.osdl.org (8.12.8/8.12.8) with ESMTP id j52M8AjA021962 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Thu, 2 Jun 2005 15:08:10 -0700 Received: from localhost (shell0.pdx.osdl.net [10.9.0.31]) by shell0.pdx.osdl.net (8.13.1/8.11.6) with ESMTP id j52M86xB021234; Thu, 2 Jun 2005 15:08:08 -0700 To: Junio C Hamano In-Reply-To: <7vwtpc60z3.fsf_-_@assigned-by-dhcp.cox.net> X-Spam-Status: No, hits=0 required=5 tests= X-Spam-Checker-Version: SpamAssassin 2.63-osdl_revision__1.40__ X-MIMEDefang-Filter: osdl$Revision: 1.109 $ X-Scanned-By: MIMEDefang 2.36 Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org 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