Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3801) use of "malloc" attribute in mem.h
Home

[Freeciv-Dev] (PR#3801) use of "malloc" attribute in mem.h

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3801) use of "malloc" attribute in mem.h
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Wed, 26 Mar 2003 12:04:09 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Hi

This code allow us use "malloc" attribute with 
fc_(malloc,calloc,realloc).
Problem is that this attribute is avilable in gcc >= 3.x then we must 
have new fc_attribute_3x macro which check gcc version.

I don't check it with gcc < 3.x then some good peoples could do it.

Rafal

----------------------------------------------------------------------
Poznam mila dziewczyne w celu... >>> http://link.interia.pl/f16f8

diff -u -r fc/common/mem.h fc2/common/mem.h
--- fc/common/mem.h     Sat May  1 05:57:23 1999
+++ fc2/common/mem.h    Wed Mar 26 20:44:32 2003
@@ -16,6 +16,7 @@
 
 #include <stdlib.h>            /* size_t; actually stddef.h, but stdlib.h
                                   might be more reliable? --dwp */
+#include "shared.h"            /* fc_attribute_3x */
 
 /* fc_malloc, fc_realloc, fc_calloc:
  * fc_ stands for freeciv; the return value is checked,
@@ -39,13 +40,13 @@
  * use the macros above instead.
  */
 void *fc_real_malloc(size_t size,
-                    const char *called_as, int line, const char *file);
+ const char *called_as, int line, const char *file) fc__attribute_3x((malloc));
 void *fc_real_realloc(void *ptr, size_t size,
-                     const char *called_as, int line, const char *file);
+ const char *called_as, int line, const char *file) fc__attribute_3x((malloc));
 void *fc_real_calloc(size_t nelem, size_t elsize,
-                    const char *called_as, int line, const char *file);
+ const char *called_as, int line, const char *file) fc__attribute_3x((malloc));
 
 char *real_mystrdup(const char *str, 
-                   const char *called_as, int line, const char *file);
+ const char *called_as, int line, const char *file) fc__attribute_3x((malloc));
 
 #endif /* FC__MEM_H */

diff -u -r fc/common/shared.h fc2/common/shared.h
--- fc/common/shared.h  Fri Dec 20 15:35:07 2002
+++ fc2/common/shared.h Wed Mar 26 20:16:44 2003
@@ -47,6 +47,12 @@
 #define fc__attribute(x)
 #endif
 
+/* for gcc >= 3.x attributes */
+#if defined(__GNUC__) && (__GNUC__ >= 3)
+#define fc__attribute_3x(x)  __attribute__(x)
+#else
+#define fc__attribute_3x(x)
+#endif
 
 /* Note: the capability string is now in capstr.c --dwp */
 /* Version stuff is now in version.h --dwp */

[Prev in Thread] Current Thread [Next in Thread]