Ejemplo n.º 1
0
Archivo: test-fact.c Proyecto: jusa/ohm
static void test_fact_store_pattern_delete (void) {
#define FACT_NAME "com.nokia.ahoy"

	OhmFactStore     *fs;
	OhmFactStoreView *v1, *v2;
	OhmPattern       *p1, *p2;
	OhmFact          *f;

	fs = ohm_fact_store_new();
	v1 = ohm_fact_store_new_view(fs, NULL);
	v2 = ohm_fact_store_new_view(fs, NULL);
	
	p1 = ohm_pattern_new(FACT_NAME);
	p2 = ohm_pattern_new(FACT_NAME);
	
	ohm_fact_store_view_add(v1, OHM_STRUCTURE(p1));
	ohm_fact_store_view_add(v2, OHM_STRUCTURE(p2));

	g_object_unref(p1);
	g_object_unref(p2);

	f = ohm_fact_new(FACT_NAME);
	ohm_fact_store_insert(fs, f);

	ohm_fact_store_view_remove(v1, OHM_STRUCTURE(p1));
	g_object_unref(v1);
	
	f = ohm_fact_new(FACT_NAME);
	ohm_fact_store_insert(fs, f);
}
Ejemplo n.º 2
0
/********************
 * dres_store_free
 ********************/
void
dres_store_free(dres_t *dres)
{
    dres_store_t *store = &dres->store;
    OhmPattern   *pattern;
    GSList       *p, *n;
    

    if (store->ht != NULL) {
        g_hash_table_destroy(store->ht);
        store->ht = NULL;
    }
    
    if (store->view != NULL) {
        for (p = store->view->patterns; p != NULL; p = n) {
            n = p->next;
            pattern = p->data;
            if (!OHM_IS_PATTERN(pattern))
                DRES_ERROR("%s@%s:%d: non-pattern object in view...",
                           __FUNCTION__, __FILE__, __LINE__);
            else {
                ohm_fact_store_view_remove(store->view, OHM_STRUCTURE(pattern));
                g_object_unref(pattern);
            }
        }

        g_object_unref(store->view);
        store->view = NULL;
    }
    
    if (store->fs) {
        g_object_unref(store->fs);
        store->fs = NULL;
    }
}