On Wed, 2011-07-27 at 16:17 +0200, Nikola Pajkovsky wrote:
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
Why is this needed?
+gint cmp_problem_data(gconstpointer a, gconstpointer b, gpointer
+ char *endptr;
+ problem_data_t *a_data = (problem_data_t *) ((GPtrArray*) a)->pdata;
This cast looks fishy.
I assume you are using this function as GCompareFunc for
The comparison function for g_ptr_array_sort() doesn't take the
pointers from the array as arguments, it takes pointers to the pointers
in the array.
IOW: a and b are not pointers to GPtrArray. Thye are pointers to
pointers STORED in a GPtrArray.
The cast as written above works by pure chance, because _GPtrArray is:
and (problem_data_t *) ((GPtrArray*) a)->pdata on assembly level
is the same as correct cast: *((problem_data_t**)a).
but if struct _GPtrArray would be
it wouldn't be.
+ const char *a_time_str =
+ unsigned long a_time= strtoul(a_time_str, &endptr, 10);
If you don't use endptr, you don't need to pass it - can just pass NULL
instead of &endptr.