]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Expose the generic archive_free hook
authorTim Kientzle <kientzle@acm.org>
Sat, 6 Apr 2013 19:17:52 +0000 (12:17 -0700)
committerTim Kientzle <kientzle@acm.org>
Sat, 6 Apr 2013 19:17:52 +0000 (12:17 -0700)
libarchive/archive.h
libarchive/archive_virtual.c

index 1e467a1bab0e2049d37138dd81db8fd559da4a3a..5281440306caa9669963daf3708f1c9222e26e46 100644 (file)
@@ -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:
index 0c4155f21e3b1f6e62ac2c45cc4033585cdba40b..de2595a9ead5365b0e036c87cdbf87830150c5f6 100644 (file)
@@ -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