[qofid.cpp] remove unnecessary struct

This commit is contained in:
Christopher Lam 2024-05-20 08:05:01 +08:00
parent fe2cdf42c7
commit 370a06fb61

View File

@ -302,40 +302,21 @@ qof_collection_set_data (QofCollection *col, gpointer user_data)
/* =============================================================== */
struct _qofid_iterate
{
QofInstanceForeachCB fcn;
gpointer data;
};
static void
foreach_cb (gpointer item, gpointer arg)
{
struct _qofid_iterate *iter = static_cast<_qofid_iterate*>(arg);
QofInstance *ent = static_cast<QofInstance*>(item);
iter->fcn (ent, iter->data);
}
void
qof_collection_foreach_sorted (const QofCollection *col, QofInstanceForeachCB cb_func,
gpointer user_data, GCompareFunc sort_fn)
{
struct _qofid_iterate iter;
GList *entries;
g_return_if_fail (col);
g_return_if_fail (cb_func);
iter.fcn = cb_func;
iter.data = user_data;
PINFO("Hash Table size of %s before is %d", col->e_type, g_hash_table_size(col->hash_of_entities));
entries = g_hash_table_get_values (col->hash_of_entities);
if (sort_fn)
entries = g_list_sort (entries, sort_fn);
g_list_foreach (entries, foreach_cb, &iter);
g_list_foreach (entries, (GFunc)cb_func, user_data);
g_list_free (entries);
PINFO("Hash Table size of %s after is %d", col->e_type, g_hash_table_size(col->hash_of_entities));