kvp frame to template and correcting failure macro

The template avoids the need to cast to and from void*, and adds flexibility to
the targeted function's signature.

test-stuff.h defines a macro, "failure" which is used as an identifier
in the standard IO library, so I moved any inclusion of test-stuff.h to
the last include position so that "failure" wouldn't be defined before
the IO library was included.
This commit is contained in:
lmat
2017-10-05 12:48:37 -04:00
parent eb6c741bf9
commit 34e0d6cfa0
27 changed files with 98 additions and 83 deletions

View File

@@ -1118,7 +1118,7 @@ static void commit_err (G_GNUC_UNUSED QofInstance *inst, QofBackendError errcode
#define GNC_FEATURES "features"
static void
add_feature_to_hash (const gchar *key, KvpValue *value, gpointer user_data)
add_feature_to_hash (const gchar *key, KvpValue *value, GHashTable * user_data)
{
gchar *descr = g_strdup(value->get<const char*>());
g_hash_table_insert (*(GHashTable**)user_data, (gchar*)key, descr);
@@ -1134,8 +1134,8 @@ qof_book_get_features (QofBook *book)
auto slot = frame->get_slot(GNC_FEATURES);
if (slot != nullptr)
{
frame = slot->get<KvpFrame*>();
frame->for_each_slot(&add_feature_to_hash, &features);
frame = slot->get<KvpFrame*>();
frame->for_each_slot_temp(&add_feature_to_hash, features);
}
return features;
}