Refactor __attribute__ usage

Use internal macros for compatibility with non GNUC compilers.
This commit is contained in:
Christian Göttsche
2020-09-09 21:35:15 +02:00
committed by cgzones
parent f4602f7b4e
commit 7107d1db0b
7 changed files with 24 additions and 24 deletions

View File

@ -53,14 +53,6 @@ void* xRealloc(void* ptr, size_t size) {
# define xStrdup(str_) (assert(str_), xStrdup_(str_))
#endif
#ifndef __has_attribute // Clang's macro
# define __has_attribute(x) 0
#endif
#if (__has_attribute(nonnull) || \
((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)))
char* xStrdup_(const char* str) __attribute__((nonnull));
#endif // __has_attribute(nonnull) || GNU C 3.3 or later
char* xStrdup_(const char* str) {
char* data = strdup(str);
if (!data) {