+#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.



_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

Reply via email to