]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Prevent unnecessary linking against deflate code 73/head
authorPaul Barker <paul@paulbarker.me.uk>
Thu, 6 Feb 2014 21:20:06 +0000 (21:20 +0000)
committerPaul Barker <paul@paulbarker.me.uk>
Sun, 6 Apr 2014 20:26:47 +0000 (21:26 +0100)
In _archive_write_disk_free, the call to deflateEnd was compiled if HAVE_ZLIB_H
was defined. However, all other calls to deflate functions were only compiled
if __APPLE__, UF_COMPRESSED and HAVE_SYS_XATTR_H were also defined. So if one of
these macros was not defined but HAVE_ZLIB_H was defined, the call the
deflateEnd would be unnecessary as deflateInit could never have been called.

In statically linked applications which don't use deflate functions elsewhere
this was causing unnecessary linking of the deflate code from zlib, adding at
least 20k of object code to the final executable size.

This patch fixes the above issue by surrounding the call to deflateEnd with the
same conditional compilation checks as surround the call to deflateInit.

Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
libarchive/archive_write_disk_posix.c

index bbd50a63764834c885d80aded47b700bce41bff8..1fac4cecfe8ea70e50be835921f85993af75dd78 100644 (file)
@@ -2215,7 +2215,8 @@ _archive_write_disk_free(struct archive *_a)
        free(a->resource_fork);
        free(a->compressed_buffer);
        free(a->uncompressed_buffer);
-#ifdef HAVE_ZLIB_H
+#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
+       && defined(HAVE_ZLIB_H)
        if (a->stream_valid) {
                switch (deflateEnd(&a->stream)) {
                case Z_OK: