From 316cbe24465143edde8f6ffb7532834b7b2ea93f Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 13 Dec 2010 16:36:33 +0200 Subject: [PATCH 1/3] Scripts: Fix gzip and bzip2 support in xzdiff. --- src/scripts/xzdiff.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/scripts/xzdiff.in b/src/scripts/xzdiff.in index 2d6e5da4..45633e0a 100644 --- a/src/scripts/xzdiff.in +++ b/src/scripts/xzdiff.in @@ -74,9 +74,9 @@ if test $# -eq 1; then *[-.]xz | *[-.]lzma | *.t[lx]z) ;; *[-.]bz2 | *.tbz | *.tbz2) - xz1=$bzip2;; + xz1=bzip2;; *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) - xz1=$gzip;; + xz1=gzip;; *) echo >&2 "$0: $1: Unknown compressed file name suffix" exit 2;; @@ -95,12 +95,12 @@ if test $# -eq 1; then ) elif test $# -eq 2; then case $1 in - *[-.]bz2 | *.tbz | *.tbz2) xz1=$bzip2;; - *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz1=$gzip;; + *[-.]bz2 | *.tbz | *.tbz2) xz1=bzip2;; + *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz1=gzip;; esac case $2 in - *[-.]bz2 | *.tbz | *.tbz2) xz2=$bzip2;; - *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz2=$gzip;; + *[-.]bz2 | *.tbz | *.tbz2) xz2=bzip2;; + *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz2=gzip;; esac case $1 in *[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | -) From f71c4e16e913f660977526f0ef8d2acdf458d7c9 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 18 Jan 2011 21:23:50 +0200 Subject: [PATCH 2/3] Add alloc_size and malloc attributes to a few functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Cristian Rodríguez for the original patch. --- src/common/sysdefs.h | 6 ++++++ src/liblzma/common/common.h | 2 +- src/xz/util.h | 5 +++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/sysdefs.h b/src/common/sysdefs.h index 51f06cf0..69370ba4 100644 --- a/src/common/sysdefs.h +++ b/src/common/sysdefs.h @@ -180,4 +180,10 @@ typedef unsigned char _Bool; # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #endif +#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 +# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x))) +#else +# define lzma_attr_alloc_size(x) +#endif + #endif diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h index 3a85168f..b8194323 100644 --- a/src/liblzma/common/common.h +++ b/src/liblzma/common/common.h @@ -205,7 +205,7 @@ struct lzma_internal_s { /// Allocates memory extern void *lzma_alloc(size_t size, lzma_allocator *allocator) - lzma_attribute((malloc)); + lzma_attribute((malloc)) lzma_attr_alloc_size(1); /// Frees memory extern void lzma_free(void *ptr, lzma_allocator *allocator); diff --git a/src/xz/util.h b/src/xz/util.h index fea8cc66..4b2d3e2f 100644 --- a/src/xz/util.h +++ b/src/xz/util.h @@ -19,11 +19,12 @@ /// \brief Safe realloc() that never returns NULL -extern void *xrealloc(void *ptr, size_t size); +extern void *xrealloc(void *ptr, size_t size) + lzma_attribute((malloc)) lzma_attr_alloc_size(2); /// \brief Safe strdup() that never returns NULL -extern char *xstrdup(const char *src); +extern char *xstrdup(const char *src) lzma_attribute((malloc)); /// \brief Fancy version of strtoull() From 7bd0a5e7ccc354f7c2e95c8bc27569c820f6a136 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 18 Jan 2011 21:25:24 +0200 Subject: [PATCH 3/3] Updated THANKS. --- THANKS | 1 + 1 file changed, 1 insertion(+) diff --git a/THANKS b/THANKS index 65c267f8..a9a22083 100644 --- a/THANKS +++ b/THANKS @@ -47,6 +47,7 @@ has been important. :-) In alphabetical order: - Mikko Pouru - Robert Readman - Bernhard Reutner-Fischer + - Cristian Rodríguez - Christian von Roques - Jukka Salmi - Alexandre Sauvé