The logic with b
is super-strange. The first time you run the code, when b
is 0, you won't call gtk_list_store_append()
, so iter1
will be left non-initialized which causes the error.
Also as pointed out by Mr Pileborg, don't cast the return value of malloc()
, and in a GTK+ program seriously consider using g_malloc()
instead. Also the size argument is scary in your code, it should be:
GType* types = g_malloc(num_fields * sizeof *types);