summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e9bee7)
raw | patch | inline | side by side (parent: 7e9bee7)
author | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 15:31:17 +0000 (17:31 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 19 Sep 2008 15:31:17 +0000 (17:31 +0200) |
When I converted the filelist from GList to GPtrArray, I missed that
the GCompareFunc does not actually get the pointers from
g_ptr_array_sort(), but pointers to the pointers... run
g_ptr_array_sort_with_data() instead with a wrapper function.
the GCompareFunc does not actually get the pointers from
g_ptr_array_sort(), but pointers to the pointers... run
g_ptr_array_sort_with_data() instead with a wrapper function.
src/filelist.c | patch | blob | history |
diff --git a/src/filelist.c b/src/filelist.c
index 6e4ebed55d84499e126bd9703c00f63c823ecc76..59fed47020d4524f1fbfc03b7423d8d5304b6d92 100644 (file)
--- a/src/filelist.c
+++ b/src/filelist.c
g_ptr_array_set_size(from->entries, 0);
}
+static gint
+filelist_compare_indirect(gconstpointer ap, gconstpointer bp, gpointer data)
+{
+ GCompareFunc compare_func = data;
+ gconstpointer a = *(const gconstpointer*)ap;
+ gconstpointer b = *(const gconstpointer*)bp;
+
+ return compare_func(a, b);
+}
+
void
filelist_sort(struct filelist *filelist, GCompareFunc compare_func)
{
- g_ptr_array_sort(filelist->entries, compare_func);
+ g_ptr_array_sort_with_data(filelist->entries,
+ filelist_compare_indirect,
+ compare_func);
}
struct filelist_entry *