aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_string.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2009-04-12 04:59:11 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2009-04-12 04:59:11 +0000
commitf8c35626c42cce880436c2936c7a4cb5860914ed (patch)
tree4f13857de195e50d5d33562e5fbbec961f5a88a9 /lib/libarchive/archive_string.c
parent0da7a22640cb13e239debde30312274ad592d5f5 (diff)
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.
Notes
Notes: svn path=/head/; revision=190956
Diffstat (limited to 'lib/libarchive/archive_string.c')
-rw-r--r--lib/libarchive/archive_string.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libarchive/archive_string.c b/lib/libarchive/archive_string.c
index 03186bfca808..120c12783feb 100644
--- a/lib/libarchive/archive_string.c
+++ b/lib/libarchive/archive_string.c
@@ -115,11 +115,11 @@ __archive_string_ensure(struct archive_string *as, size_t 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_string *as, size_t 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;