D_BUS_REPLY_NULL(invocation);
}
-void heart_storage_delete_cb(struct logging_table_form *table, void *user_data)
+void heart_storage_delete_cb(gpointer data, gpointer user_data)
{
int ret;
+ struct logging_table_form *table = (struct logging_table_form *)data;
if (!table) {
_E("the table is empty!");
_SE("Delete request failed: %s", table->data);
}
+void heart_storage_collect_candidate(struct logging_table_form *table, void *user_data)
+{
+ GPtrArray *candidates = (GPtrArray *)user_data;
+ if (!candidates) {
+ _E("There is no array to store candidates");
+ return;
+ }
+
+ g_ptr_array_add(candidates, table);
+}
+
void *heart_storage_verifying_thread_main(void *arg)
{
int ret;
char *pkgid;
+ GPtrArray *candidates = g_ptr_array_new();
+
+ if (!candidates) {
+ _E("Failed to create GPtrArray");
+ goto end;
+ }
_D("Verifying thread is created!");
do {
pthread_mutex_unlock(&heart_storage_verifying_mutex);
_SD("Verify '%s'", pkgid);
- ret = logging_read_foreach(STORAGE_NAME, NULL, pkgid, 0, 0, heart_storage_delete_cb, NULL);
+ ret = logging_read_foreach(STORAGE_NAME, NULL, pkgid, 0, 0,
+ heart_storage_collect_candidate, candidates);
if (ret != RESOURCED_ERROR_NONE)
_E("Failed to read logs! : %d", ret);
free(pkgid);
+
+ g_ptr_array_foreach(candidates, heart_storage_delete_cb, NULL);
+ g_ptr_array_free(candidates, TRUE);
} while (1);
- heart_storage_verifying_thread = 0;
pthread_mutex_unlock(&heart_storage_verifying_mutex);
+
+end:
+ heart_storage_verifying_thread = 0;
pthread_exit((void *)0);
}