Inserting non-pod struct into a GHashTable
- by RikSaunderson
Hi there,
I'm trying to build a GHashTable of instances of a struct containing ints, a time_t and a few char*'s.
My question is, how do you insert an instance of a struct into a GHashTable? there are plenty of examples of how to insert a string or an int (using g_str_hash and g_int_hash respectively), but I'm guessing thatI want to use the g_direct_hash, and I can't seem to find any examples of that.
Ideally, my code would look like this:
GHashtable table;
table = g_hash_table_new(g_direct_hash, g_direct_equal);
struct mystruct;
mystruct.a = 1;
mystruct.b = "hello";
mystruct.c = 5;
mystruct.d = "test";
g_hash_table_insert(table,mystruct.a,mystruct);
Clearly, this is incorrect as it does not compile. Can anyone provide an example that does do what I want?
Thanks,
Rik