From owner-svn-src-head@FreeBSD.ORG Tue Dec 29 15:48:05 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C443106568B; Tue, 29 Dec 2009 15:48:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B2178FC0A; Tue, 29 Dec 2009 15:48:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBTFm5IS028645; Tue, 29 Dec 2009 15:48:05 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBTFm5xd028643; Tue, 29 Dec 2009 15:48:05 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200912291548.nBTFm5xd028643@svn.freebsd.org> From: John Baldwin Date: Tue, 29 Dec 2009 15:48:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201202 - head/usr.sbin/arp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2009 15:48:05 -0000 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;