glib: Drop G_GNUC_MALLOC usage from various other allocation functions

These functions may be OK to leave the G_GNUC_MALLOC attribute on,
because the only valid pointers in the storage areas they return are,
themselves, new pointers.

However, it’s a lot easier to remove the attributes now than to try and
diagnose miscompilations in future. The performance impact of this is
likely to be unmeasurable. If there are performance problems caused by
this, then they can be profiled and fixed case-by-case in future,
bearing in mind the possibility for miscompilation if G_GNUC_MALLOC is
readded.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1465
This commit is contained in:
Philip Withnall 2018-08-22 11:15:08 +01:00
parent 082730fc3e
commit c849a4ddd3
5 changed files with 13 additions and 13 deletions

View File

@ -146,7 +146,7 @@ GLIB_AVAILABLE_IN_ALL
gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark,
const gchar *uri, const gchar *uri,
gsize *length, gsize *length,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_bookmark_file_add_application (GBookmarkFile *bookmark, void g_bookmark_file_add_application (GBookmarkFile *bookmark,
const gchar *uri, const gchar *uri,
@ -161,7 +161,7 @@ GLIB_AVAILABLE_IN_ALL
gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark,
const gchar *uri, const gchar *uri,
gsize *length, gsize *length,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark, gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
const gchar *uri, const gchar *uri,
@ -228,7 +228,7 @@ GLIB_AVAILABLE_IN_ALL
gint g_bookmark_file_get_size (GBookmarkFile *bookmark); gint g_bookmark_file_get_size (GBookmarkFile *bookmark);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark,
gsize *length) G_GNUC_MALLOC; gsize *length);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark,
const gchar *uri, const gchar *uri,

View File

@ -170,7 +170,7 @@ GLIB_AVAILABLE_IN_ALL
gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar **g_uri_list_extract_uris (const gchar *uri_list) G_GNUC_MALLOC; gchar **g_uri_list_extract_uris (const gchar *uri_list);
G_END_DECLS G_END_DECLS

View File

@ -106,12 +106,12 @@ GLIB_AVAILABLE_IN_ALL
gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC; gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar **g_key_file_get_groups (GKeyFile *key_file, gchar **g_key_file_get_groups (GKeyFile *key_file,
gsize *length) G_GNUC_MALLOC; gsize *length);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar **g_key_file_get_keys (GKeyFile *key_file, gchar **g_key_file_get_keys (GKeyFile *key_file,
const gchar *group_name, const gchar *group_name,
gsize *length, gsize *length,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gboolean g_key_file_has_group (GKeyFile *key_file, gboolean g_key_file_has_group (GKeyFile *key_file,
const gchar *group_name); const gchar *group_name);
@ -212,7 +212,7 @@ gchar **g_key_file_get_string_list (GKeyFile *key_file,
const gchar *group_name, const gchar *group_name,
const gchar *key, const gchar *key,
gsize *length, gsize *length,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_key_file_set_string_list (GKeyFile *key_file, void g_key_file_set_string_list (GKeyFile *key_file,
const gchar *group_name, const gchar *group_name,
@ -225,7 +225,7 @@ gchar **g_key_file_get_locale_string_list (GKeyFile *key_file,
const gchar *key, const gchar *key,
const gchar *locale, const gchar *locale,
gsize *length, gsize *length,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_key_file_set_locale_string_list (GKeyFile *key_file, void g_key_file_set_locale_string_list (GKeyFile *key_file,
const gchar *group_name, const gchar *group_name,

View File

@ -34,11 +34,11 @@ typedef struct _GMappedFile GMappedFile;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GMappedFile *g_mapped_file_new (const gchar *filename, GMappedFile *g_mapped_file_new (const gchar *filename,
gboolean writable, gboolean writable,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
GMappedFile *g_mapped_file_new_from_fd (gint fd, GMappedFile *g_mapped_file_new_from_fd (gint fd,
gboolean writable, gboolean writable,
GError **error) G_GNUC_MALLOC; GError **error);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gsize g_mapped_file_get_length (GMappedFile *file); gsize g_mapped_file_get_length (GMappedFile *file);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View File

@ -270,18 +270,18 @@ typedef gchar** GStrv;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar** g_strsplit (const gchar *string, gchar** g_strsplit (const gchar *string,
const gchar *delimiter, const gchar *delimiter,
gint max_tokens) G_GNUC_MALLOC; gint max_tokens);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar ** g_strsplit_set (const gchar *string, gchar ** g_strsplit_set (const gchar *string,
const gchar *delimiters, const gchar *delimiters,
gint max_tokens) G_GNUC_MALLOC; gint max_tokens);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar* g_strjoinv (const gchar *separator, gchar* g_strjoinv (const gchar *separator,
gchar **str_array) G_GNUC_MALLOC; gchar **str_array) G_GNUC_MALLOC;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
void g_strfreev (gchar **str_array); void g_strfreev (gchar **str_array);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar** g_strdupv (gchar **str_array) G_GNUC_MALLOC; gchar** g_strdupv (gchar **str_array);
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
guint g_strv_length (gchar **str_array); guint g_strv_length (gchar **str_array);