emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs & MAXPATHLEN


From: Jan D.
Subject: Re: emacs & MAXPATHLEN
Date: Sat, 30 Jul 2005 13:27:23 +0200


+#else
+      {
+        int buf_size = 2;
+        buf = xmalloc (buf_size);
+        for(;;)
+          {
+            if(getcwd (buf, buf_size) == 0)
+              {
+                if(errno == ERANGE)
+                  {
+                    buf_size *= 2;
+                    buf = xrealloc (buf, buf_size);
+                  }
+                else
+                  fatal ("`getcwd' failed: %s\n", strerror (errno));
+              }
+            else
+              break;
+          }
+
+      }
+#endif


You can initialize buf_size to something bigger than 2. This almost guarantees multiple calls to realloc. Try 1024 or something more reasonable that will at least hold most paths. 2 will only hold "/" and nothing else.

Also, space after if and for.

    Jan D.





reply via email to

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