glib2/allocsize.patch

65 lines
2.7 KiB
Diff

--- glib/gmacros.h
+++ 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)))
--- glib/gmem.h
+++ glib/gmem.h
@@ -44,13 +44,13 @@
/* Memory allocation functions
*/
-gpointer g_malloc (gulong n_bytes) G_GNUC_MALLOC;
-gpointer g_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
+gpointer g_malloc (gulong n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
+gpointer g_malloc0 (gulong n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
gpointer g_realloc (gpointer mem,
gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
void g_free (gpointer mem);
-gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC;
-gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
+gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
+gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
gpointer g_try_realloc (gpointer mem,
gulong n_bytes) G_GNUC_WARN_UNUSED_RESULT;
--- glib/gslice.h
+++ glib/gslice.h
@@ -29,10 +29,10 @@
/* 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,
--- glib/gstrfuncs.h
+++ glib/gstrfuncs.h
@@ -214,7 +214,7 @@
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