From owner-svn-src-head@FreeBSD.ORG Sun Apr 12 04:59:12 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 05C9A106568A; Sun, 12 Apr 2009 04:59:12 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E80958FC19; Sun, 12 Apr 2009 04:59:11 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3C4xBbF011184; Sun, 12 Apr 2009 04:59:11 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3C4xB6D011182; Sun, 12 Apr 2009 04:59:11 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200904120459.n3C4xB6D011182@svn.freebsd.org> From: Tim Kientzle Date: Sun, 12 Apr 2009 04:59:11 +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: r190956 - head/lib/libarchive 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: Sun, 12 Apr 2009 04:59:12 -0000 Author: kientzle Date: Sun Apr 12 04:59:11 2009 New Revision: 190956 URL: http://svn.freebsd.org/changeset/base/190956 Log: Merge from libarchive.googlecode.com: r751: Change __archive_strncat() to use a void * source, which reduces the amount of casting needed to use this with "char", "signed char" and "unsigned char". r752: Use additions instead of multiplications when growing buffer; faster and less chance of overflow. Modified: head/lib/libarchive/archive_string.c head/lib/libarchive/archive_string.h Modified: head/lib/libarchive/archive_string.c ============================================================================== --- head/lib/libarchive/archive_string.c Sun Apr 12 04:45:40 2009 (r190955) +++ head/lib/libarchive/archive_string.c Sun Apr 12 04:59:11 2009 (r190956) @@ -115,11 +115,11 @@ __archive_string_ensure(struct archive_s as->buffer_length = 32; else if (as->buffer_length < 8192) /* Buffers under 8k are doubled for speed. */ - as->buffer_length *= 2; + as->buffer_length += as->buffer_length; else { /* Buffers 8k and over grow by at least 25% each time. */ size_t old_length = as->buffer_length; - as->buffer_length = (as->buffer_length * 5) / 4; + as->buffer_length += as->buffer_length / 4; /* Be safe: If size wraps, release buffer and return NULL. */ if (as->buffer_length < old_length) { free(as->s); @@ -142,10 +142,12 @@ __archive_string_ensure(struct archive_s } struct archive_string * -__archive_strncat(struct archive_string *as, const char *p, size_t n) +__archive_strncat(struct archive_string *as, const void *_p, size_t n) { size_t s; - const char *pp; + const char *p, *pp; + + p = (const char *)_p; /* Like strlen(p), except won't examine positions beyond p[n]. */ s = 0; Modified: head/lib/libarchive/archive_string.h ============================================================================== --- head/lib/libarchive/archive_string.h Sun Apr 12 04:45:40 2009 (r190955) +++ head/lib/libarchive/archive_string.h Sun Apr 12 04:59:11 2009 (r190956) @@ -99,8 +99,12 @@ __archive_string_ensure(struct archive_s #define archive_string_ensure __archive_string_ensure /* Append C string, which may lack trailing \0. */ +/* The source is declared void * here because this gets used with + * "signed char *", "unsigned char *" and "char *" arguments. + * Declaring it "char *" as with some of the other functions just + * leads to a lot of extra casts. */ struct archive_string * -__archive_strncat(struct archive_string *, const char *, size_t); +__archive_strncat(struct archive_string *, const void *, size_t); #define archive_strncat __archive_strncat /* Append a C string to an archive_string, resizing as necessary. */