Add __malloc_like macro to apply __malloc__ attribute to emalloc,
ecalloc and estrdup. It cannot be applied to realloc since that may return the same pointer.
This commit is contained in:
@@ -22,13 +22,13 @@
|
|||||||
int easprintf(char **, const char *, ...) __printflike(2, 3);
|
int easprintf(char **, const char *, ...) __printflike(2, 3);
|
||||||
int evasprintf(char **, const char *, va_list) __printflike(2, 0);
|
int evasprintf(char **, const char *, va_list) __printflike(2, 0);
|
||||||
void efree(void *);
|
void efree(void *);
|
||||||
void *ecalloc(size_t, size_t);
|
void *ecalloc(size_t, size_t) __malloc_like;
|
||||||
void *emalloc(size_t);
|
void *emalloc(size_t) __malloc_like;
|
||||||
void *emalloc2(size_t, size_t);
|
void *emalloc2(size_t, size_t) __malloc_like;
|
||||||
void *erealloc(void *, size_t);
|
void *erealloc(void *, size_t);
|
||||||
void *erealloc3(void *, size_t, size_t);
|
void *erealloc3(void *, size_t, size_t);
|
||||||
void *erecalloc(void *, size_t, size_t, size_t);
|
void *erecalloc(void *, size_t, size_t, size_t);
|
||||||
char *estrdup(const char *);
|
char *estrdup(const char *) __malloc_like;
|
||||||
char *estrndup(const char *, size_t);
|
char *estrndup(const char *, size_t) __malloc_like;
|
||||||
|
|
||||||
#endif /* _SUDO_ALLOC_H */
|
#endif /* _SUDO_ALLOC_H */
|
||||||
|
@@ -52,6 +52,15 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Hint to compiler that returned pointer is unique (malloc but not realloc). */
|
||||||
|
#ifndef __malloc_like
|
||||||
|
# if __GNUC_PREREQ__(2, 96)
|
||||||
|
# define __malloc_like __attribute__((__malloc__))
|
||||||
|
# else
|
||||||
|
# define __malloc_like
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __dso_public
|
#ifndef __dso_public
|
||||||
# ifdef HAVE_DSO_VISIBILITY
|
# ifdef HAVE_DSO_VISIBILITY
|
||||||
# if defined(__GNUC__)
|
# if defined(__GNUC__)
|
||||||
|
Reference in New Issue
Block a user