1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-28 08:02:54 +00:00

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.
This commit is contained in:
Maxim Konovalov 2005-01-24 17:01:48 +00:00
parent ed41980cbb
commit 19beed5e2e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140748

View File

@ -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;