From mboxrd@z Thu Jan 1 00:00:00 1970 From: Antoine Pelisse Subject: Re: [PATCH 1/2] entry.c: convert checkout_entry to use strbuf Date: Wed, 23 Oct 2013 15:06:16 +0200 Message-ID: References: <20131021193223.GC29681@sigill.intra.peff.net> <1382532907-30561-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: git , Erik Faye-Lund , Johannes Sixt , =?UTF-8?Q?Torsten_B=C3=83=C2=B6gershausen?= , Wataru Noguchi , Johannes Schindelin , =?UTF-8?B?UmVuw4PCqSBTY2hhcmZl?= , msysGit To: Duy Nguyen X-From: msysgit+bncBD3NZH6HQMJBBSMTT6JQKGQEUWFEYTA@googlegroups.com Wed Oct 23 15:06:21 2013 Return-path: Envelope-to: gcvm-msysgit@m.gmane.org Received: from mail-ea0-f191.google.com ([209.85.215.191]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VYy8g-0002pp-2f for gcvm-msysgit@m.gmane.org; Wed, 23 Oct 2013 15:06:18 +0200 Received: by mail-ea0-f191.google.com with SMTP id o10sf90553eaj.28 for ; Wed, 23 Oct 2013 06:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=qYbX8J8RHPnv7EAqrj7c0cX1dC4ClbrxwHKaS8vwkNA=; b=XfF7ER0afrLnnobtnlji/WyfygaYmLl5LGZ7bDrUyyoqlVP2C6rplA/Orl+CEo1x5D 2gOikBFGXEx4jxQ1LOZM64hHQhsM+HZ04VEQzRegTFhzhY4qoSfz1JQ0nbemuIm4iI+o UwA+/BkJWamVUwjPUXAGDIZOCV1vt8LlisQm6VKDILRM0/6n/fnaZKhcvN0KB1Dq90bS YqdHicqYcMZr6MQubmF+FZ8aj7z0XSMzNqaBA3quZEFVtwsIYPX+NT/bZAQcCF3imRAm 6A2hj02uiAb5TDdFEuoA0y1ddUNLfeNy8NjhyFMNyKHess2a1YOYICWvYvOkS40qPbd7 koMw== X-Received: by 10.152.28.3 with SMTP id x3mr6519lag.33.1382533577783; Wed, 23 Oct 2013 06:06:17 -0700 (PDT) X-BeenThere: msysgit@googlegroups.com Received: by 10.152.27.3 with SMTP id p3ls116245lag.64.gmail; Wed, 23 Oct 2013 06:06:17 -0700 (PDT) X-Received: by 10.152.21.165 with SMTP id w5mr626291lae.3.1382533577103; Wed, 23 Oct 2013 06:06:17 -0700 (PDT) Received: from mail-la0-x22c.google.com (mail-la0-x22c.google.com [2a00:1450:4010:c03::22c]) by gmr-mx.google.com with ESMTPS id re4si2068203bkb.1.2013.10.23.06.06.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Oct 2013 06:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of apelisse@gmail.com designates 2a00:1450:4010:c03::22c as permitted sender) client-ip=2a00:1450:4010:c03::22c; Received: by mail-la0-f44.google.com with SMTP id ep20so635574lab.31 for ; Wed, 23 Oct 2013 06:06:16 -0700 (PDT) X-Received: by 10.152.29.103 with SMTP id j7mr1158937lah.7.1382533576747; Wed, 23 Oct 2013 06:06:16 -0700 (PDT) Received: by 10.112.50.240 with HTTP; Wed, 23 Oct 2013 06:06:16 -0700 (PDT) In-Reply-To: X-Original-Sender: apelisse@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of apelisse@gmail.com designates 2a00:1450:4010:c03::22c as permitted sender) smtp.mail=apelisse@gmail.com; dkim=pass header.i=@gmail.com; dmarc=pass (p=NONE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list msysgit@googlegroups.com; contact msysgit+owners@googlegroups.com List-ID: X-Google-Group-Id: 152234828034 List-Post: , List-Help: , List-Archive: Sender: msysgit@googlegroups.com List-Subscribe: , List-Unsubscribe: , Archived-At: On Wed, Oct 23, 2013 at 3:04 PM, Duy Nguyen wrote: > On Wed, Oct 23, 2013 at 7:58 PM, Antoine Pelisse wrote: >>> diff --git a/entry.c b/entry.c >>> index acc892f..d955af5 100644 >>> --- a/entry.c >>> +++ b/entry.c >>> @@ -237,16 +237,18 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen) >>> int checkout_entry(struct cache_entry *ce, >>> const struct checkout *state, char *topath) >>> { >>> - static char path[PATH_MAX + 1]; >>> + static struct strbuf path_buf = STRBUF_INIT; >>> + char *path; >>> struct stat st; >>> - int len = state->base_dir_len; >>> + int len; >>> >>> if (topath) >>> return write_entry(ce, topath, state, 1); >>> >>> - memcpy(path, state->base_dir, len); >>> - strcpy(path + len, ce->name); >>> - len += ce_namelen(ce); >>> + strbuf_reset(&path_buf); >> >> I think this is not required > > If you mean strbuf_reset, I think it is. path_buf is still static (I > don't want to remove that because it'll add a lot more strbuf_release) > so we can't be sure what it contains from the second checkout_entry() > call. Of course, I forgot about the static, Thanks :-) -- -- *** Please reply-to-all at all times *** *** (do not pretend to know who is subscribed and who is not) *** *** Please avoid top-posting. *** The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free. You received this message because you are subscribed to the Google Groups "msysGit" group. To post to this group, send email to msysgit@googlegroups.com To unsubscribe from this group, send email to msysgit+unsubscribe@googlegroups.com For more options, and view previous threads, visit this group at http://groups.google.com/group/msysgit?hl=en_US?hl=en --- You received this message because you are subscribed to the Google Groups "msysGit" group. To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.