summaryrefslogtreecommitdiffstats
path: root/usr.sbin/arp
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-12-29 15:48:04 +0000
committerjhb <jhb@FreeBSD.org>2009-12-29 15:48:04 +0000
commitab90bdba3f74c4a0f83f3cd2ff1da154105e6d3d (patch)
tree831dfa8f83bedcddcee8fad9a5325c2ae25be883 /usr.sbin/arp
parentfb28939ce7beb7a398a69e31346008d37d6dfbb0 (diff)
downloadFreeBSD-src-ab90bdba3f74c4a0f83f3cd2ff1da154105e6d3d.zip
FreeBSD-src-ab90bdba3f74c4a0f83f3cd2ff1da154105e6d3d.tar.gz
Use reallocf() to simplify some logic.
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/arp')
-rw-r--r--usr.sbin/arp/arp.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index 8a3410f..2982f48 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -493,7 +493,7 @@ search(u_long addr, action_fn *action)
{
int mib[6];
size_t needed;
- char *lim, *buf, *newbuf, *next;
+ char *lim, *buf, *next;
struct rt_msghdr *rtm;
struct sockaddr_inarp *sin2;
struct sockaddr_dl *sdl;
@@ -516,13 +516,9 @@ search(u_long addr, action_fn *action)
return 0;
buf = NULL;
for (;;) {
- newbuf = realloc(buf, needed);
- if (newbuf == NULL) {
- if (buf != NULL)
- free(buf);
+ buf = reallocf(buf, needed);
+ if (buf == NULL)
errx(1, "could not reallocate memory");
- }
- buf = newbuf;
st = sysctl(mib, 6, buf, &needed, NULL, 0);
if (st == 0 || errno != ENOMEM)
break;
OpenPOWER on IntegriCloud