From owner-svn-src-head@FreeBSD.ORG Thu Jun 12 19:01:59 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 20F6991B; Thu, 12 Jun 2014 19:01:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E7F52DD3; Thu, 12 Jun 2014 19:01:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5CJ1wmq004609; Thu, 12 Jun 2014 19:01:58 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5CJ1wwJ004606; Thu, 12 Jun 2014 19:01:58 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201406121901.s5CJ1wwJ004606@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 12 Jun 2014 19:01:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267426 - head/usr.bin/patch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 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: Thu, 12 Jun 2014 19:01:59 -0000 Author: pfg Date: Thu Jun 12 19:01:57 2014 New Revision: 267426 URL: http://svnweb.freebsd.org/changeset/base/267426 Log: Avoid zeroing during allocation. This change reverts a change from OpenBSD which made use of calloc, and therefore wasted time initializing arrays that will later be realloc'ed. Consistently use FreeBSD's reallocf(). While here also merge the changes from OpenBSD's manpage patch.1 Rev 1.27: "patch was moved from user portability (UP) to base in issue 7 and is no longer optional" MFC after: 1 week Modified: head/usr.bin/patch/patch.1 head/usr.bin/patch/pch.c Modified: head/usr.bin/patch/patch.1 ============================================================================== --- head/usr.bin/patch/patch.1 Thu Jun 12 18:59:25 2014 (r267425) +++ head/usr.bin/patch/patch.1 Thu Jun 12 19:01:57 2014 (r267426) @@ -19,9 +19,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: patch.1,v 1.26 2010/09/03 11:09:29 jmc Exp $ +.\" $OpenBSD: patch.1,v 1.27 2014/04/15 06:26:54 jmc Exp $ .\" $FreeBSD$ -.Dd January 29, 2013 +.Dd June 12, 2014 .Dt PATCH 1 .Os .Sh NAME @@ -639,13 +639,10 @@ The .Nm utility is compliant with the .St -p1003.1-2008 -specification -(except as detailed above for the +specification, +except as detailed above for the .Fl -posix -option), -though the presence of -.Nm -itself is optional. +option. .Pp The flags .Op Fl BCEFfstVvxz Modified: head/usr.bin/patch/pch.c ============================================================================== --- head/usr.bin/patch/pch.c Thu Jun 12 18:59:25 2014 (r267425) +++ head/usr.bin/patch/pch.c Thu Jun 12 19:01:57 2014 (r267426) @@ -132,11 +132,11 @@ void set_hunkmax(void) { if (p_line == NULL) - p_line = calloc((size_t) hunkmax, sizeof(char *)); + p_line = malloc((size_t) hunkmax * sizeof(char *)); if (p_len == NULL) - p_len = calloc((size_t) hunkmax, sizeof(short)); + p_len = malloc((size_t) hunkmax * sizeof(short)); if (p_char == NULL) - p_char = calloc((size_t) hunkmax, sizeof(char)); + p_char = malloc((size_t) hunkmax * sizeof(char)); } /* @@ -155,17 +155,9 @@ grow_hunkmax(void) if (p_line == NULL || p_len == NULL || p_char == NULL) fatal("Internal memory allocation error\n"); - new_p_line = realloc(p_line, new_hunkmax * sizeof(char *)); - if (new_p_line == NULL) - free(p_line); - - new_p_len = realloc(p_len, new_hunkmax * sizeof(short)); - if (new_p_len == NULL) - free(p_len); - - new_p_char = realloc(p_char, new_hunkmax * sizeof(char)); - if (new_p_char == NULL) - free(p_char); + new_p_line = reallocf(p_line, new_hunkmax * sizeof(char *)); + new_p_len = reallocf(p_len, new_hunkmax * sizeof(short)); + new_p_char = reallocf(p_char, new_hunkmax * sizeof(char)); p_char = new_p_char; p_len = new_p_len;