summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-02-24 08:40:41 +0100
committerTimm Bäder <mail@baedert.org>2018-02-25 16:47:20 +0100
commitdc1612b86568b58b88d9a25dc19871fc2b2b42f3 (patch)
treecbce2f9a5063098021f90bf78212deb3eac0b1ec /gdk
parent7d7045bc35db48acbd8f8ffbd133f975efb90848 (diff)
downloadgtk+-dc1612b86568b58b88d9a25dc19871fc2b2b42f3.tar.gz
contentsformat: Avoid a GPtrArray
We know how many items this array will have in advance, so just malloc enough.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkcontentformats.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index cd3293f0a3..95a8a608ae 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -147,18 +147,20 @@ GdkContentFormats *
gdk_content_formats_new (const char **mime_types,
guint n_mime_types)
{
- GPtrArray *array;
guint i;
+ const char **mime_types_copy;
if (n_mime_types == 0)
return gdk_content_formats_new_take (NULL, 0, NULL, 0);
- array = g_ptr_array_new ();
+ mime_types_copy = g_new (const char *, n_mime_types + 1);
+
for (i = 0; i < n_mime_types; i++)
- g_ptr_array_add (array, (gpointer) g_intern_string (mime_types[i]));
- g_ptr_array_add (array, NULL);
+ mime_types_copy[i] = g_intern_string (mime_types[i]);
+
+ mime_types_copy[n_mime_types] = NULL;
- return gdk_content_formats_new_take (NULL, 0, (const char **) g_ptr_array_free (array, FALSE), n_mime_types);
+ return gdk_content_formats_new_take (NULL, 0, mime_types_copy, n_mime_types);
}
/**