diff options
author | Mike Frysinger <vapier@gentoo.org> | 2006-01-06 04:08:00 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2006-01-06 04:08:00 +0000 |
commit | 17cb1552310b7745c873ab98580d3ea0ed91878e (patch) | |
tree | d12befbeff145a2ddd0499536341885aa16d129f /libc | |
parent | 4f0d889f74cd8ecf441ac8f5f719945b13fb5181 (diff) |
rework the alloca() loop slightly to save some space
Diffstat (limited to 'libc')
-rw-r--r-- | libc/inet/if_index.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libc/inet/if_index.c b/libc/inet/if_index.c index 5837faa65..abfb26e00 100644 --- a/libc/inet/if_index.c +++ b/libc/inet/if_index.c @@ -101,21 +101,19 @@ if_nameindex (void) rq_len = RQ_IFS * sizeof (struct ifreq); /* Read all the interfaces out of the kernel. */ - ifc.ifc_buf = alloca (rq_len); - ifc.ifc_len = rq_len; - while (1) + /* Note: alloca's in this loop are diff from glibc because it's smaller */ + do { + ifc.ifc_buf = extend_alloca (ifc.ifc_buf, rq_len, 2 * rq_len); + ifc.ifc_len = rq_len; + if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0) { __close (fd); return NULL; } - if (ifc.ifc_len < rq_len) - break; - - ifc.ifc_buf = extend_alloca (ifc.ifc_buf, rq_len, 2 * rq_len); - ifc.ifc_len = rq_len; } + while (ifc.ifc_len == rq_len); nifs = ifc.ifc_len / sizeof(struct ifreq); |