diff options
Diffstat (limited to 'common/eurephia_nullsafe.c')
-rw-r--r-- | common/eurephia_nullsafe.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/eurephia_nullsafe.c b/common/eurephia_nullsafe.c index f70b463..5f507c3 100644 --- a/common/eurephia_nullsafe.c +++ b/common/eurephia_nullsafe.c @@ -38,6 +38,12 @@ #include <eurephia_context.h> #include <eurephia_log.h> +#if __GNUC__ >= 3 +#define __malloc__ __attribute__((malloc)) +#else /* If not GCC 3 or newer, disable optimisations */ +#define __malloc__ +#endif + /** * Internal function, should be called via the malloc_nullsafe() macro. * This replaces the use of malloc() and memset(). This function uses calloc @@ -51,7 +57,7 @@ * * @return Returns a void pointer to the memory region on success, otherwise NULL */ -void *__malloc_nullsafe(eurephiaCTX *ctx, size_t sz, const char *file, int line) { +__malloc__ void *_malloc_nullsafe(eurephiaCTX *ctx, size_t sz, const char *file, int line) { void *buf = NULL; buf = calloc(1, sz); /* Using calloc, also gives a zero'd memory region */ @@ -88,7 +94,7 @@ void *__malloc_nullsafe(eurephiaCTX *ctx, size_t sz, const char *file, int line) * @param line debug info, which line in the file * */ -void inline __free_nullsafe(eurephiaCTX *ctx, void *ptr, const char *file, int line) { +void inline _free_nullsafe(eurephiaCTX *ctx, void *ptr, const char *file, int line) { if( ptr == NULL ) { return; } |