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:
Todd C. Miller
2013-03-05 10:18:32 -05:00
parent c47f5f7abd
commit 4e5baccb9c
2 changed files with 14 additions and 5 deletions

View File

@@ -52,6 +52,15 @@
# 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
# ifdef HAVE_DSO_VISIBILITY
# if defined(__GNUC__)