g_ptr_array_sort_[with_data] is twisted
Submitted by Owen Taylor
Link to original bug (#113697)
Description
What's wrong with the following code?
g_ptr_array_sort (ptr_array, (GCompareFunc)strcmp);
Answer:
The comparison function for g_ptr_array_sort_[with_data] doesn't take the the pointers from the array, it takes pointers to the pointers in the array.
This was, I suspect, an accidental oversight, but I doubt we can change it at this point.
Two possible steps moving forward:
-
Add warning notes to the docs with big exclamation points (Should definitely do this)
-
Add another set of functions that behave as expected and deprecate the current ones. I don't know what you would call the new functions.
Version: 2.2.x