mirror of https://git.tukaani.org/xz.git
Add alloc_size and malloc attributes to a few functions.
Thanks to Cristian Rodríguez for the original patch.
This commit is contained in:
parent
316cbe2446
commit
f71c4e16e9
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue