[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49417] trunk/blender: Fix warnings on old apple GCC compiler due to no support for alloc_size attribute .
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Jul 31 17:05:09 CEST 2012
Revision: 49417
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49417
Author: blendix
Date: 2012-07-31 15:05:09 +0000 (Tue, 31 Jul 2012)
Log Message:
-----------
Fix warnings on old apple GCC compiler due to no support for alloc_size attribute.
Modified Paths:
--------------
trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
trunk/blender/source/blender/blenlib/BLI_memarena.h
Modified: trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
===================================================================
--- trunk/blender/intern/guardedalloc/MEM_guardedalloc.h 2012-07-31 14:27:14 UTC (rev 49416)
+++ trunk/blender/intern/guardedalloc/MEM_guardedalloc.h 2012-07-31 15:05:09 UTC (rev 49417)
@@ -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 @@
* 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 @@
* 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 @@
* 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 @@
* 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 @@
* 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 @@
* 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 @@
/** 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
;
Modified: trunk/blender/source/blender/blenlib/BLI_memarena.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_memarena.h 2012-07-31 14:27:14 UTC (rev 49416)
+++ trunk/blender/source/blender/blenlib/BLI_memarena.h 2012-07-31 15:05:09 UTC (rev 49417)
@@ -47,41 +47,44 @@
*/
#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)))
More information about the Bf-blender-cvs
mailing list