namespace {
-void _move(gpointer key, gpointer value, gpointer user_data) {
+gboolean _move_func(gpointer key, gpointer value, gpointer user_data) {
application_x* appinfo = static_cast<application_x*>(value);
std::vector<application_x*>* app_list =
static_cast<std::vector<application_x*>*>(user_data);
app_list->emplace_back(appinfo);
+ return true;
+}
+
+void __free_applications(gpointer data) {
+ pkgmgrinfo_basic_free_application((application_x*)data);
}
} // namespace
if (!Connect()) return PMINFO_R_ERROR;
GHashTable* list = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, NULL);
+ NULL, __free_applications);
std::vector<sqlite3*> conn_list = GetConnection();
int ret = PMINFO_R_OK;
for (auto conn : conn_list) {
GetLocale().c_str(), list);
if (ret == PMINFO_R_ERROR) {
_LOGE("Failed to appinfo_internal_filter_get_list (%d)", ret);
- g_hash_table_destroy(list);
break;
}
}
- g_hash_table_foreach(list, _move, &handle_list_);
+ if (ret == PMINFO_R_OK)
+ g_hash_table_foreach_steal(list, _move_func, &handle_list_);
+
g_hash_table_destroy(list);
return ret;
}