From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giuseppe Scrivano Newsgroups: gmane.emacs.devel Subject: Re: emacs & MAXPATHLEN Date: Sat, 30 Jul 2005 14:58:03 +0200 Message-ID: <873bpwxxgk.fsf@gmail.com> 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=us-ascii X-Trace: sea.gmane.org 1122730627 4578 80.91.229.2 (30 Jul 2005 13:37:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Jul 2005 13:37:07 +0000 (UTC) Cc: "Jan D." , 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:36:58 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DyrWK-0008Lr-DR for ged-emacs-devel@m.gmane.org; Sat, 30 Jul 2005 15:36:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyrYs-0007Ix-Ha for ged-emacs-devel@m.gmane.org; Sat, 30 Jul 2005 09:39:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DyrXk-00070b-Io for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:38:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DyrXi-0006zz-R9 for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:38:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DyrWq-0006Km-2B for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:37:28 -0400 Original-Received: from [64.233.170.194] (helo=rproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Dyr6F-0007xr-GE for emacs-devel@gnu.org; Sat, 30 Jul 2005 09:09:59 -0400 Original-Received: by rproxy.gmail.com with SMTP id c16so1246415rne for ; Sat, 30 Jul 2005 05:57:56 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:to:cc:subject:references:from:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=L57v4h30bTXFxkkrf+braoz35GV38Nv9l4jmk3xj+3SK0/h2crg2HKPqmZPVzKZwUk456FCRqVm2Aul2UY45+PJhod8qgXiioI9EALn05hMRtkGdnFLleZ+iVfWO9Q9f9FoKxJe2seRp2pkcWxKQwJLKXynq8VZPXX26s52biL8= Original-Received: by 10.38.12.2 with SMTP id 2mr860859rnl; Sat, 30 Jul 2005 05:57:56 -0700 (PDT) Original-Received: from steel ([80.181.159.241]) by mx.gmail.com with ESMTP id 71sm2956454rnc.2005.07.30.05.57.54; Sat, 30 Jul 2005 05:57:56 -0700 (PDT) Original-Received: from gscrivano by steel with local (Exim 4.52) id 1Dyquh-0001xY-RE; Sat, 30 Jul 2005 14:58:03 +0200 Original-To: ams@gnu.org 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.11 (Gnus v5.11) 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:41343 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41343 Well.. this code seems cleaner than the older one and without memory leaks :) "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 = 100; > while (1) > { > buf = (char *) xmalloc (buf_size); > if (getcwd (buf, buf_size) == buf) > break; > free (buf); > if (errno != ERANGE) > fatal ("`getcwd' failed: %s\n", strerror (errno)); > size *= 2; > }