preset: fix sorting presets
authorStefan Sauer <ensonic@users.sf.net>
Sun, 11 Jan 2015 22:00:29 +0000 (23:00 +0100)
committerStefan Sauer <ensonic@users.sf.net>
Sun, 11 Jan 2015 22:02:57 +0000 (23:02 +0100)
The glib docs are not clear on this, but the qsort man-page is - the
GCompareDataFunc does not get the strings, but pointers to them.

gst/gstpreset.c

index ee5a4a5..d105d9d 100644 (file)
@@ -428,6 +428,12 @@ preset_get_keyfile (GstPreset * preset)
   return presets;
 }
 
+static gint
+compare_strings (gchar ** a, gchar ** b, gpointer user_data)
+{
+  return g_strcmp0 (*a, *b);
+}
+
 /* get a list of all supported preset names for an element */
 static gchar **
 gst_preset_default_get_preset_names (GstPreset * preset)
@@ -464,7 +470,7 @@ gst_preset_default_get_preset_names (GstPreset * preset)
 
   /* sort the array now */
   g_qsort_with_data (groups, num_groups, sizeof (gchar *),
-      (GCompareDataFunc) strcmp, NULL);
+      (GCompareDataFunc) compare_strings, NULL);
 
   return groups;