这是我的代码:
gint compare_ulong_function (gconstpointer a, gconstpointer b)
{
return *(unsigned long *)a - *(unsigned long *)b;
}
GArray* build_priority_queue(unsigned char* const input_data, unsigned int const input_size)
{
GArray* priority_queue = g_array_sized_new(FALSE, TRUE, sizeof(unsigned long), 256);
int i;
for (i = 0; i < input_size; i++)
g_array_index(priority_queue, unsigned long, input_data[i])++;
g_array_sort(priority_queue, compare_ulong_function);
return priority_queue;
}
当我调试 g_array_sort 被调用(无法进入缺少开发包的函数并且无法安装它)但数组未排序。compare_ulong_function 永远不会被调用。