emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs & MAXPATHLEN


From: Andreas Schwab
Subject: Re: emacs & MAXPATHLEN
Date: Sat, 30 Jul 2005 15:11:53 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

"Alfred M. Szmidt" <address@hidden> 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)

At this point errno may already be changed by free().  Why not just use
xrealloc in the first place?

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]