aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorJoakim Verona2011-08-27 19:45:48 +0200
committerJoakim Verona2011-08-27 19:45:48 +0200
commit9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4 (patch)
treee94476d49f15747fcb9409d773702e88201855a4 /src/process.c
parentc7489583c30031c0ecfae9d20b20c149ca1935e9 (diff)
parentb75258b32810f3690442bddef2e10eef126d2d25 (diff)
downloademacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.tar.gz
emacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.zip
upstream
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c41
1 files changed, 8 insertions, 33 deletions
diff --git a/src/process.c b/src/process.c
index 977cfb964e2..a8088322147 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3573,52 +3573,27 @@ format; see the description of ADDRESS in `make-network-process'. */)
3573 struct ifconf ifconf; 3573 struct ifconf ifconf;
3574 struct ifreq *ifreq; 3574 struct ifreq *ifreq;
3575 void *buf = NULL; 3575 void *buf = NULL;
3576 int buf_size = 512, s, i; 3576 ptrdiff_t buf_size = 512;
3577 int s, i;
3577 Lisp_Object res; 3578 Lisp_Object res;
3578 3579
3579 s = socket (AF_INET, SOCK_STREAM, 0); 3580 s = socket (AF_INET, SOCK_STREAM, 0);
3580 if (s < 0) 3581 if (s < 0)
3581 return Qnil; 3582 return Qnil;
3582 3583
3583 ifconf.ifc_buf = 0; 3584 do
3584 ifconf.ifc_len = 0;
3585 if (ioctl (s, SIOCGIFCONF, &ifconf) == 0 && ifconf.ifc_len > 0)
3586 { 3585 {
3587 ifconf.ifc_buf = xmalloc (ifconf.ifc_len); 3586 buf = xpalloc (buf, &buf_size, 1, INT_MAX, 1);
3588 if (ifconf.ifc_buf == NULL) 3587 ifconf.ifc_buf = buf;
3589 { 3588 ifconf.ifc_len = buf_size;
3590 close (s);
3591 return Qnil;
3592 }
3593 if (ioctl (s, SIOCGIFCONF, &ifconf)) 3589 if (ioctl (s, SIOCGIFCONF, &ifconf))
3594 { 3590 {
3595 close (s); 3591 close (s);
3596 xfree (ifconf.ifc_buf); 3592 xfree (buf);
3597 return Qnil; 3593 return Qnil;
3598 } 3594 }
3599 } 3595 }
3600 else 3596 while (ifconf.ifc_len == buf_size);
3601 do
3602 {
3603 buf_size *= 2;
3604 buf = xrealloc (buf, buf_size);
3605 if (!buf)
3606 {
3607 close (s);
3608 return Qnil;
3609 }
3610
3611 ifconf.ifc_buf = buf;
3612 ifconf.ifc_len = buf_size;
3613 if (ioctl (s, SIOCGIFCONF, &ifconf))
3614 {
3615 close (s);
3616 xfree (buf);
3617 return Qnil;
3618 }
3619
3620 }
3621 while (ifconf.ifc_len == buf_size);
3622 3597
3623 close (s); 3598 close (s);
3624 3599