svn commit: r202164 - stable/8/usr.sbin/arp

John Baldwin jhb at FreeBSD.org
Tue Jan 12 18:47:41 UTC 2010


Author: jhb
Date: Tue Jan 12 18:47:40 2010
New Revision: 202164
URL: http://svn.freebsd.org/changeset/base/202164

Log:
  MFC 201202:
  Use reallocf() to simplify some logic.

Modified:
  stable/8/usr.sbin/arp/arp.c
Directory Properties:
  stable/8/usr.sbin/arp/   (props changed)

Modified: stable/8/usr.sbin/arp/arp.c
==============================================================================
--- stable/8/usr.sbin/arp/arp.c	Tue Jan 12 18:20:20 2010	(r202163)
+++ stable/8/usr.sbin/arp/arp.c	Tue Jan 12 18:47:40 2010	(r202164)
@@ -499,7 +499,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;
@@ -522,13 +522,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;


More information about the svn-src-stable mailing list