diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-07-31 19:05:09 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-07-31 19:05:09 +0400 |
commit | aac3f0eaebd155eca29b62cad322687bfd30dc1f (patch) | |
tree | f24cc46bb42aea6dc19a1117a167e96a453124ba | |
parent | c42d0189e586419269e9004868bec365e1b8396f (diff) |
Fix warnings on old apple GCC compiler due to no support for alloc_size attribute.
-rw-r--r-- | intern/guardedalloc/MEM_guardedalloc.h | 17 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_memarena.h | 15 |
2 files changed, 19 insertions, 13 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 65ce7baba1e..ae8115a337e 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -63,6 +63,9 @@ #include <stdio.h> /* needed for FILE* */ #include "MEM_sys_types.h" /* needed for uintptr_t */ +/* some GNU attributes are only available from GCC 4.3 */ +#define MEM_GNU_ATTRIBUTES (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) + #ifdef __cplusplus extern "C" { #endif @@ -71,7 +74,7 @@ extern "C" { * by vmemh. If the pointer was not previously allocated by this * module, the result is undefined.*/ size_t MEM_allocN_len(const void *vmemh) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) #endif ; @@ -90,7 +93,7 @@ extern "C" { * Duplicates a block of memory, and returns a pointer to the * newly allocated block. */ void *MEM_dupallocN(void *vmemh) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) #endif ; @@ -101,7 +104,7 @@ extern "C" { * as a system realloc but just makes a new allocation and copies * over from existing memory. */ void *MEM_reallocN(void *vmemh, size_t len) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((alloc_size(2))) #endif @@ -112,7 +115,7 @@ extern "C" { * memory is cleared. The name must be static, because only a * pointer to it is stored ! */ void *MEM_callocN(size_t len, const char *str) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((nonnull(2))) __attribute__((alloc_size(1))) @@ -124,7 +127,7 @@ extern "C" { * name must be a static, because only a pointer to it is stored ! * */ void *MEM_mallocN(size_t len, const char *str) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((nonnull(2))) __attribute__((alloc_size(1))) @@ -136,7 +139,7 @@ extern "C" { * Can be free'd with MEM_freeN as usual. * */ void *MEM_mapallocN(size_t len, const char *str) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((nonnull(2))) __attribute__((alloc_size(1))) @@ -188,7 +191,7 @@ extern "C" { /** Get the peak memory usage in bytes, including mmap allocations. */ uintptr_t MEM_get_peak_memory(void) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) #endif ; diff --git a/source/blender/blenlib/BLI_memarena.h b/source/blender/blenlib/BLI_memarena.h index 2a2dd31b26f..092bb639b91 100644 --- a/source/blender/blenlib/BLI_memarena.h +++ b/source/blender/blenlib/BLI_memarena.h @@ -47,41 +47,44 @@ extern "C" { */ #define BLI_MEMARENA_STD_BUFSIZE (1 << 14) +/* some GNU attributes are only available from GCC 4.3 */ +#define MEM_GNU_ATTRIBUTES (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) + struct MemArena; typedef struct MemArena MemArena; struct MemArena *BLI_memarena_new(const int bufsize, const char *name) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((nonnull(2))) #endif ; void BLI_memarena_free(struct MemArena *ma) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((nonnull(1))) #endif ; void BLI_memarena_use_malloc(struct MemArena *ma) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((nonnull(1))) #endif ; void BLI_memarena_use_calloc(struct MemArena *ma) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((nonnull(1))) #endif ; void BLI_memarena_use_align(struct MemArena *ma, const int align) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((nonnull(1))) #endif ; void *BLI_memarena_alloc(struct MemArena *ma, int size) -#ifdef __GNUC__ +#if MEM_GNU_ATTRIBUTES __attribute__((warn_unused_result)) __attribute__((nonnull(1))) __attribute__((alloc_size(2))) |