From mboxrd@z Thu Jan 1 00:00:00 1970 From: nguyenhu@minatec.inpg.fr Subject: Re: [PATCHv6 1/4] Read (but not write) from $XDG_CONFIG_HOME/git/config file Date: Tue, 12 Jun 2012 00:59:49 +0200 Message-ID: <20120612005949.Horde.2Iy7T3wdC4BP1nhlOdxxKdA@webmail.minatec.grenoble-inp.fr> References: <1338754481-27012-1-git-send-email-Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr> <1338988885-21933-1-git-send-email-Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr> <7vpq9aenl0.fsf@alter.siamese.dyndns.org> <20120608142601.Horde.Tq7UO3wdC4BP0e9ZGAy1EwA@webmail.minatec.grenoble-inp.fr> <7vvcj1dep7.fsf@alter.siamese.dyndns.org> <20120609125336.Horde.iUq0R3wdC4BP0yswpGlGBZA@webmail.minatec.grenoble-inp.fr> <7v4nqjbrdo.fsf@alter.siamese.dyndns.org> <20120610154850.Horde.gYrJO3wdC4BP1KXCOvLEiCA@webmail.minatec.grenoble-inp.fr> <7v8vft97a8.fsf@alter.siamese.dyndns.org> <20120611185311.Horde.RALabXwdC4BP1iJ3aQ-w89A@webmail.minatec.grenoble-inp.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed DelSp=Yes Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Erik Faye-Lund , Junio C Hamano , Huynh Khoi Nguyen NGUYEN , Matthieu.Moy@grenoble-inp.fr, Valentin Duperray , Franck Jonas , Lucien Kong , Thomas Nguy To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Jun 12 01:00:02 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SeDaa-0001Dq-C8 for gcvg-git-2@plane.gmane.org; Tue, 12 Jun 2012 01:00:00 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628Ab2FKW7z convert rfc822-to-quoted-printable (ORCPT ); Mon, 11 Jun 2012 18:59:55 -0400 Received: from v-smtp.minatec.grenoble-inp.fr ([147.173.216.28]:33846 "EHLO v-smtp.minatec.grenoble-inp.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664Ab2FKW7y (ORCPT ); Mon, 11 Jun 2012 18:59:54 -0400 Received: from localhost (www02.minatec.grenoble-inp.fr [147.173.216.15]) by v-smtp.minatec.grenoble-inp.fr (Postfix) with ESMTP id DC7951A02F6; Tue, 12 Jun 2012 00:59:49 +0200 (CEST) Received: from etu-190-212.vpn-inp.grenoble-inp.fr (etu-190-212.vpn-inp.grenoble-inp.fr [147.171.190.212]) by webmail.minatec.grenoble-inp.fr (Horde Framework) with HTTP; Tue, 12 Jun 2012 00:59:49 +0200 In-Reply-To: <20120611185311.Horde.RALabXwdC4BP1iJ3aQ-w89A@webmail.minatec.grenoble-inp.fr> User-Agent: Internet Messaging Program (IMP) H4 (5.0.17) Content-Disposition: inline Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: nguyenhu@minatec.inpg.fr a =E9crit=A0: > Junio C Hamano a =E9crit=A0: > >> Erik Faye-Lund writes: >> >>> The awkward thing about doing this, is that the memory allocated by >>> the strbuf cannot be reclaimed if you go with this. A pointer that = has >>> been adjusted (like cleanup_path can do) cannot be successfully fed= to >>> free. >> >> Yeah, I wouldn't recommend doing that. Either >> >> path =3D strbuf_detach(&sb, NULL); >> retval =3D xstrdup(cleanup_path(path)); >> free(path); >> return retval; >> >> or >> >> path =3D xstrdup(cleanup_path(sb.buf)); >> strbuf_release(&sb); >> return path; >> >> would be more sensible. In our next patch, mkpathdup() function will be char *mkpathdup(const char *fmt, ...) { char *path; struct strbuf sb =3D STRBUF_INIT; va_list args; va_start(args, fmt); strbuf_vaddf(&sb, fmt, args); va_end(args); path =3D xstrdup(cleanup_path(sb.buf)); strbuf_release(&sb); return path; } which looks like our previous proposal with xstrdup() and cleanup_path() functions at the right place.