File glib2-allocsize.patch of Package glib2

Index: glib/gmacros.h
===================================================================
--- glib/gmacros.h.orig
+++ glib/gmacros.h
@@ -63,6 +63,14 @@
 #define G_GNUC_NULL_TERMINATED
 #endif
 
+#if     (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
+#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
+#else
+#define G_GNUC_ALLOC_SIZE(x)
+#define G_GNUC_ALLOC_SIZE2(x)
+#endif
+
 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
 #define G_GNUC_PRINTF( format_idx, arg_idx )    \
   __attribute__((__format__ (__printf__, format_idx, arg_idx)))
Index: glib/gmem.h
===================================================================
--- glib/gmem.h.orig
+++ glib/gmem.h
@@ -44,13 +44,13 @@ typedef struct _GMemVTable GMemVTable;
 
 /* Memory allocation functions
  */
-gpointer g_malloc         (gsize	 n_bytes) G_GNUC_MALLOC;
-gpointer g_malloc0        (gsize	 n_bytes) G_GNUC_MALLOC;
+gpointer g_malloc         (gsize	 n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
+gpointer g_malloc0        (gsize	 n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
 gpointer g_realloc        (gpointer	 mem,
 			   gsize	 n_bytes) G_GNUC_WARN_UNUSED_RESULT;
 void	 g_free	          (gpointer	 mem);
-gpointer g_try_malloc     (gsize	 n_bytes) G_GNUC_MALLOC;
-gpointer g_try_malloc0    (gsize	 n_bytes) G_GNUC_MALLOC;
+gpointer g_try_malloc     (gsize	 n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
+gpointer g_try_malloc0    (gsize	 n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
 gpointer g_try_realloc    (gpointer	 mem,
 			   gsize	 n_bytes) G_GNUC_WARN_UNUSED_RESULT;
 
Index: glib/gslice.h
===================================================================
--- glib/gslice.h.orig
+++ glib/gslice.h
@@ -29,10 +29,10 @@ G_BEGIN_DECLS
 
 /* slices - fast allocation/release of small memory blocks
  */
-gpointer g_slice_alloc          	(gsize	       block_size) G_GNUC_MALLOC;
-gpointer g_slice_alloc0         	(gsize         block_size) G_GNUC_MALLOC;
+gpointer g_slice_alloc          	(gsize	       block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
+gpointer g_slice_alloc0         	(gsize         block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
 gpointer g_slice_copy                   (gsize         block_size,
-                                         gconstpointer mem_block) G_GNUC_MALLOC;
+                                         gconstpointer mem_block) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
 void     g_slice_free1          	(gsize         block_size,
 					 gpointer      mem_block);
 void     g_slice_free_chain_with_offset (gsize         block_size,
Index: glib/gstrfuncs.h
===================================================================
--- glib/gstrfuncs.h.orig
+++ glib/gstrfuncs.h
@@ -214,7 +214,7 @@ gchar*                g_strescape      (
 					const gchar *exceptions) G_GNUC_MALLOC;
 
 gpointer              g_memdup	       (gconstpointer mem,
-					guint	       byte_size) G_GNUC_MALLOC;
+					guint	       byte_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(2);
 
 /* NULL terminated string arrays.
  * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens
openSUSE Build Service is sponsored by