Add alloc_size for libiberty memory allocation functions.
2019-06-10 Martin Liska <mliska@suse.cz> * ansidecl.h: (ATTRIBUTE_RESULT_SIZE_1): Define new macro. (ATTRIBUTE_RESULT_SIZE_2): Likewise. (ATTRIBUTE_RESULT_SIZE_1_2): Likewise. * libiberty.h (xmalloc): Add RESULT_SIZE attribute. (xrealloc): Likewise. (xcalloc): Likewise. From-SVN: r272109
This commit is contained in:
parent
74ac8f1fe9
commit
3bb0dcb6c0
3 changed files with 38 additions and 3 deletions
|
@ -1,3 +1,13 @@
|
|||
2019-06-10 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* ansidecl.h:
|
||||
(ATTRIBUTE_RESULT_SIZE_1): Define new macro.
|
||||
(ATTRIBUTE_RESULT_SIZE_2): Likewise.
|
||||
(ATTRIBUTE_RESULT_SIZE_1_2): Likewise.
|
||||
* libiberty.h (xmalloc): Add RESULT_SIZE attribute.
|
||||
(xrealloc): Likewise.
|
||||
(xcalloc): Likewise.
|
||||
|
||||
2019-04-26 Michael Forney <mforney@mforney.org>
|
||||
|
||||
* libiberty.h (vasprintf): Don't declare if HAVE_DECL_VASPRINTF
|
||||
|
|
|
@ -292,6 +292,31 @@ So instead we use the macro below and test it against specific values. */
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* Attribute `alloc_size' was valid as of gcc 4.3. */
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_1
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_2
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_RESULT_SIZE_1_2
|
||||
# if (GCC_VERSION >= 4003)
|
||||
# define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2)))
|
||||
# else
|
||||
# define ATTRIBUTE_RESULT_SIZE_1_2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* We use __extension__ in some places to suppress -pedantic warnings
|
||||
about GCC extensions. This feature didn't work properly before
|
||||
gcc 2.8. */
|
||||
|
|
|
@ -310,18 +310,18 @@ extern void xmalloc_failed (size_t) ATTRIBUTE_NORETURN;
|
|||
message to stderr (using the name set by xmalloc_set_program_name,
|
||||
if any) and then call xexit. */
|
||||
|
||||
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_1;
|
||||
|
||||
/* Reallocate memory without fail. This works like xmalloc. Note,
|
||||
realloc type functions are not suitable for attribute malloc since
|
||||
they may return the same address across multiple calls. */
|
||||
|
||||
extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL;
|
||||
extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_2;
|
||||
|
||||
/* Allocate memory without fail and set it to zero. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
|
||||
extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_1_2;
|
||||
|
||||
/* Copy a string into a memory buffer without fail. */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue