X-Git-Url: http://git.maemo.org/git/?p=scdataviz;a=blobdiff_plain;f=matdb.c;h=644eb4021623f573f4716c8a8adbcad67c8ded16;hp=891bec5a97ac96c9818861cc5866206441f0e301;hb=f3ddf2cd811f53afd0edaa3b1263035d9faab318;hpb=b3d75c36341a21496fe61e25c61acfe10bb8ced5 diff --git a/matdb.c b/matdb.c index 891bec5..644eb40 100644 --- a/matdb.c +++ b/matdb.c @@ -27,15 +27,19 @@ static void print_property(gpointer key, gpointer value, gpointer user_data) { fprintf(stderr, "\t\t%s=%g:\n", (char*)key, *(double*)value); } +static void print_inner_bowing(gpointer key, gpointer value, gpointer user_data) { + struct matdb_bowing *bowing = (struct matdb_bowing*)value; + fprintf(stderr, "\tbowing %s:%s[%s:%s]:\n", bowing->from->str, bowing->to->str, (char*)user_data, (char*)key); + g_hash_table_foreach(bowing->properties, &print_property, NULL); +} static void print_material(gpointer key, gpointer value, gpointer user_data) { struct matdb_material *mat = (struct matdb_material*)value; fprintf(stderr, "\tmaterial %s(%s):\n", mat->name->str, (char*)key); - g_hash_table_foreach(mat->properties, print_property, NULL); + g_hash_table_foreach(mat->properties, &print_property, NULL); } static void print_bowing(gpointer key, gpointer value, gpointer user_data) { - struct matdb_bowing *bowing = (struct matdb_bowing*)value; - fprintf(stderr, "\tbowing %s:%s(%s):\n", bowing->from->str, bowing->to->str, (char*)key); - g_hash_table_foreach(bowing->properties, print_property, NULL); + GHashTable *ht = value; + g_hash_table_foreach(ht, &print_inner_bowing, key); } void print_matdb(const struct matdb *mdb) { @@ -51,13 +55,19 @@ void destroy_bowing_gpointer(gpointer data) { destroy_bowing((struct matdb_bowing *)data); } void destroy_material(struct matdb_material *mat) { - free(mat->name); + #ifdef DEBUG + fprintf(stderr, "destroy_material\n"); + #endif + g_string_free(mat->name, TRUE); g_hash_table_unref(mat->properties); free(mat); } void destroy_bowing(struct matdb_bowing *bow) { - free(bow->from); - free(bow->to); + #ifdef DEBUG + fprintf(stderr, "destroy_bowing\n"); + #endif + g_string_free(bow->from, TRUE); + g_string_free(bow->to, TRUE); g_hash_table_unref(bow->properties); free(bow); }