Date: Tue, 29 Dec 2009 15:48:05 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r201202 - head/usr.sbin/arp Message-ID: <200912291548.nBTFm5xd028643@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Tue Dec 29 15:48:04 2009 New Revision: 201202 URL: http://svn.freebsd.org/changeset/base/201202 Log: Use reallocf() to simplify some logic. MFC after: 2 weeks Modified: head/usr.sbin/arp/arp.c Modified: head/usr.sbin/arp/arp.c ============================================================================== --- head/usr.sbin/arp/arp.c Tue Dec 29 14:29:08 2009 (r201201) +++ head/usr.sbin/arp/arp.c Tue Dec 29 15:48:04 2009 (r201202) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912291548.nBTFm5xd028643>