Merge from trunk.
[bpt/emacs.git] / src / process.c
index 9d20d0c..887090d 100644 (file)
@@ -3570,7 +3570,8 @@ format; see the description of ADDRESS in `make-network-process'.  */)
   struct ifconf ifconf;
   struct ifreq *ifreq;
   void *buf = NULL;
-  int buf_size = 512, s, i;
+  ptrdiff_t buf_size = 512;
+  int s, i;
   Lisp_Object res;
 
   s = socket (AF_INET, SOCK_STREAM, 0);
@@ -3578,15 +3579,10 @@ format; see the description of ADDRESS in `make-network-process'.  */)
     return Qnil;
 
  again:
-  buf_size *= 2;
-  buf = xrealloc(buf, buf_size);
-  if (!buf)
-    {
-      close (s);
-      return Qnil;
-    }
 
+  buf = xpalloc (buf, &buf_size, sizeof *ifreq, INT_MAX, 1);
   ifconf.ifc_buf = buf;
+  ifconf.ifc_len = buf_size;
   if (ioctl (s, SIOCGIFCONF, &ifconf))
     {
       close (s);