diff options
author | maxim <maxim@FreeBSD.org> | 2005-01-24 17:01:48 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2005-01-24 17:01:48 +0000 |
commit | 688ee30636e90289d8837cddb63ed17322c91b71 (patch) | |
tree | cbd068813baa9089ff218b584f2e5e92edd5841e | |
parent | 3441ac65f830a5e88b963e48060d42b04dc11194 (diff) | |
download | FreeBSD-src-688ee30636e90289d8837cddb63ed17322c91b71.zip FreeBSD-src-688ee30636e90289d8837cddb63ed17322c91b71.tar.gz |
o Reorganize the previous delta to make it more style(9) compliant.
Submitted by: ru
o Reduce an amount of memory we ask in advance.
-rw-r--r-- | usr.sbin/arp/arp.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 32c0bc2..5a22ea8 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -474,8 +474,7 @@ search(u_long addr, action_fn *action) if (needed == 0) /* empty table */ return 0; buf = NULL; - do { - needed += needed / 2; + for (;;) { newbuf = realloc(buf, needed); if (newbuf == NULL) { if (buf != NULL) @@ -484,7 +483,10 @@ search(u_long addr, action_fn *action) } buf = newbuf; st = sysctl(mib, 6, buf, &needed, NULL, 0); - } while (st == -1 && errno == ENOMEM); + if (st == 0 || errno != ENOMEM) + break; + needed += needed / 8; + } if (st == -1) err(1, "actual retrieval of routing table"); lim = buf + needed; |