Date: Sat, 6 Dec 2008 05:56:44 +0000 (UTC) From: Tim Kientzle <kientzle@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185667 - head/lib/libarchive Message-ID: <200812060556.mB65ui5s084395@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kientzle Date: Sat Dec 6 05:56:43 2008 New Revision: 185667 URL: http://svn.freebsd.org/changeset/base/185667 Log: New internal archive_string_concat utility function. 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 Sat Dec 6 05:55:46 2008 (r185666) +++ head/lib/libarchive/archive_string.c Sat Dec 6 05:56:43 2008 (r185667) @@ -70,6 +70,18 @@ __archive_string_copy(struct archive_str } void +__archive_string_concat(struct archive_string *dest, struct archive_string *src) +{ + if (src->length > 0) { + if (__archive_string_ensure(dest, dest->length + src->length + 1) == NULL) + __archive_errx(1, "Out of memory"); + memcpy(dest->s + dest->length, src->s, src->length); + dest->length += src->length; + dest->s[dest->length] = 0; + } +} + +void __archive_string_free(struct archive_string *as) { as->length = 0; Modified: head/lib/libarchive/archive_string.h ============================================================================== --- head/lib/libarchive/archive_string.h Sat Dec 6 05:55:46 2008 (r185666) +++ head/lib/libarchive/archive_string.h Sat Dec 6 05:56:43 2008 (r185667) @@ -92,6 +92,12 @@ __archive_string_copy(struct archive_str #define archive_string_copy(dest, src) \ __archive_string_copy(dest, src) +/* Concatenate one archive_string to another */ +void +__archive_string_concat(struct archive_string *dest, struct archive_string *src); +#define archive_string_concat(dest, src) \ + __archive_string_concat(dest, src) + /* Ensure that the underlying buffer is at least as large as the request. */ struct archive_string * __archive_string_ensure(struct archive_string *, size_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812060556.mB65ui5s084395>