aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-09-11 18:53:31 +0300
committerLasse Collin <lasse.collin@tukaani.org>2023-09-22 20:06:27 +0300
commit18a66fbac031c98f9c2077fc88846e4d07849197 (patch)
treef348bae228b00567059a3533c38b5d11978fd9d5 /src/liblzma/common
parentBuild: Omit -Wc99-c11-compat since it warns about _Noreturn. (diff)
downloadxz-18a66fbac031c98f9c2077fc88846e4d07849197.tar.xz
Remove incorrect uses of __attribute__((__malloc__)).
xrealloc() is obviously incorrect, modern GCC docs even mention realloc() as an example where this attribute cannot be used. liblzma's lzma_alloc() and lzma_alloc_zero() would be correct uses most of the time but custom allocators may use a memory pool or otherwise hold the pointer so aliasing issues could happen in theory. The xstrdup() case likely was correct but I removed it anyway. Now there are no __malloc__ attributes left in the code. The allocations aren't in hot paths so this should make no practical difference.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/common.c4
-rw-r--r--src/liblzma/common/common.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/liblzma/common/common.c b/src/liblzma/common/common.c
index baad3dd8..02a10641 100644
--- a/src/liblzma/common/common.c
+++ b/src/liblzma/common/common.c
@@ -35,7 +35,7 @@ lzma_version_string(void)
// Memory allocation //
///////////////////////
-extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
+extern void * lzma_attr_alloc_size(1)
lzma_alloc(size_t size, const lzma_allocator *allocator)
{
// Some malloc() variants return NULL if called with size == 0.
@@ -53,7 +53,7 @@ lzma_alloc(size_t size, const lzma_allocator *allocator)
}
-extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
+extern void * lzma_attr_alloc_size(1)
lzma_alloc_zero(size_t size, const lzma_allocator *allocator)
{
// Some calloc() variants return NULL if called with size == 0.
diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h
index 4d9cab53..cea9f9b3 100644
--- a/src/liblzma/common/common.h
+++ b/src/liblzma/common/common.h
@@ -298,12 +298,12 @@ struct lzma_internal_s {
/// Allocates memory
extern void *lzma_alloc(size_t size, const lzma_allocator *allocator)
- lzma_attribute((__malloc__)) lzma_attr_alloc_size(1);
+ lzma_attr_alloc_size(1);
/// Allocates memory and zeroes it (like calloc()). This can be faster
/// than lzma_alloc() + memzero() while being backward compatible with
/// custom allocators.
-extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
+extern void * lzma_attr_alloc_size(1)
lzma_alloc_zero(size_t size, const lzma_allocator *allocator);
/// Frees memory