From: Tim Kientzle Date: Sat, 6 Apr 2013 19:17:52 +0000 (-0700) Subject: Expose the generic archive_free hook X-Git-Tag: v3.1.900a~351^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ae99fbc24d504ebefdcf83e9758e6337dbd387d;p=thirdparty%2Flibarchive.git Expose the generic archive_free hook --- diff --git a/libarchive/archive.h b/libarchive/archive.h index 1e467a1ba..528144030 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -880,6 +880,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *, int (*_metadata_filter_func)(struct archive *, void *, struct archive_entry *), void *_client_data); +/* Simplified cleanup interface; + * This calls archive_read_free() or archive_write_free() as needed. */ +__LA_DECL int archive_free(struct archive *); + /* * Accessor functions to read/set various information in * the struct archive object: diff --git a/libarchive/archive_virtual.c b/libarchive/archive_virtual.c index 0c4155f21..de2595a9e 100644 --- a/libarchive/archive_virtual.c +++ b/libarchive/archive_virtual.c @@ -54,6 +54,14 @@ archive_filter_bytes(struct archive *a, int n) return ((a->vtable->archive_filter_bytes)(a, n)); } +int +archive_free(struct archive *a) +{ + if (a == NULL) + return (ARCHIVE_OK); + return ((a->vtable->archive_free)(a)); +} + int archive_write_close(struct archive *a) { @@ -76,9 +84,7 @@ archive_write_fail(struct archive *a) int archive_write_free(struct archive *a) { - if (a == NULL) - return (ARCHIVE_OK); - return ((a->vtable->archive_free)(a)); + return archive_free(a); } #if ARCHIVE_VERSION_NUMBER < 4000000 @@ -93,9 +99,7 @@ archive_write_finish(struct archive *a) int archive_read_free(struct archive *a) { - if (a == NULL) - return (ARCHIVE_OK); - return ((a->vtable->archive_free)(a)); + return archive_free(a); } #if ARCHIVE_VERSION_NUMBER < 4000000