From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: emacs & MAXPATHLEN Date: Sat, 30 Jul 2005 15:11:53 +0200 Message-ID: References: <87fytzj6a7.fsf@gmail.com> <87pst2h35e.fsf@gmail.com> <87r7dhxenv.fsf@gmail.com> <1122724192.075506.1144.nullmailer@Update.UU.SE> <1122727837.129884.1319.nullmailer@Update.UU.SE> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1122730874 5042 80.91.229.2 (30 Jul 2005 13:41:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Jul 2005 13:41:14 +0000 (UTC) Cc: "Jan D." , gscrivano@gmail.com, rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 30 15:41:12 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyraM-0000Br-UP for ged-emacs-devel@m.gmane.org; Sat, 30 Jul 2005 15:41:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dyrcu-0000YL-TJ for ged-emacs-devel@m.gmane.org; Sat, 30 Jul 2005 09:43:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dyrby-00006g-K0 for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:42:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dyrbw-000069-PE for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:42:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyrWn-0006Km-2n for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:37:25 -0400 Original-Received: from [195.135.220.2] (helo=mx1.suse.de) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DyrJn-0008Uh-81; Sat, 30 Jul 2005 09:23:59 -0400 Original-Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id C9ED3F1ED; Sat, 30 Jul 2005 15:11:53 +0200 (CEST) Original-To: ams@gnu.org X-Yow: .. One FISHWICH coming up!! In-Reply-To: <1122727837.129884.1319.nullmailer@Update.UU.SE> (Alfred M. Szmidt's message of "Sat, 30 Jul 2005 14:50:37 +0200") User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:41345 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41345 "Alfred M. Szmidt" writes: > and leaks memory. If the path is 400, you do 3 mallocs, but the > first two are never freed. > > That is just a small matter of moving the free outside the if. :-) > > int buf_size =3D 100; > while (1) > { > buf =3D (char *) xmalloc (buf_size); > if (getcwd (buf, buf_size) =3D=3D buf) > break; > free (buf); > if (errno !=3D ERANGE) At this point errno may already be changed by free(). Why not just use xrealloc in the first place? Andreas. --=20 Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra=DFe 5, 90409 N=FCrnberg, Germany Key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."