|
From: | Jan D. |
Subject: | Re: emacs & MAXPATHLEN |
Date: | Sat, 30 Jul 2005 14:23:55 +0200 |
How about the following instead... It is far cleaner and easier to understand. int buf_size = 100; while (1) { buf = (char *) xmalloc (buf_size); if (getcwd (buf, buf_size) == buf) break; if (errno != ERANGE) { free (buf); fatal ("`getcwd' failed: %s\n", strerror (errno)); } size *= 2; }
and leaks memory. If the path is 400, you do 3 mallocs, but the first two are never freed.
Jan D.
[Prev in Thread] | Current Thread | [Next in Thread] |