THRIFT-2690
c_glib: Incorrect behaviour when serializing a map with typedef'd keys

Patch: Simon South
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 632dbc7..96ce99e 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -2971,8 +2971,8 @@
     t_type *tval = ((t_map *) ttype)->get_val_type();
     string tkey_name = type_name (tkey);
     string tval_name = type_name (tval);
-    string tkey_ptr = tkey->is_string() || !tkey->is_base_type() ? "" : "*";
-    string tval_ptr = tval->is_string() || !tval->is_base_type() ? "" : "*";
+    string tkey_ptr;
+    string tval_ptr;
     string keyname = tmp("key");
     string valname = tmp("val");
 
@@ -2993,6 +2993,15 @@
       indent() << "GList *key_list = NULL, *iter = NULL;" << endl;
     declare_local_variable(out, tkey, keyname);
     declare_local_variable(out, tval, valname);
+
+    /* If either the key or value type is a typedef, find its underlying type so
+       we can correctly determine how to generate a pointer to it */
+    tkey = get_true_type(tkey);
+    tval = get_true_type(tval);
+
+    tkey_ptr = tkey->is_string() || !tkey->is_base_type() ? "" : "*";
+    tval_ptr = tval->is_string() || !tval->is_base_type() ? "" : "*";
+
     out <<
       indent() << "g_hash_table_foreach ((GHashTable *) " << prefix << 
                    ", thrift_hash_table_get_keys, &key_list);" << endl <<
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 48ece70..f4e3250 100755
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -471,7 +471,7 @@
   // insanity
   insanity_out = (TTestInsanity *) g_object_new (T_TEST_TYPE_INSANITY, NULL);
   insanity_out->userMap = g_hash_table_new (NULL, NULL);
-  g_hash_table_insert (insanity_out->userMap, &enum_out, &user_id_out);
+  g_hash_table_insert (insanity_out->userMap, GINT_TO_POINTER (enum_out), &user_id_out);
 
   xtruct1 = (TTestXtruct *) g_object_new (T_TEST_TYPE_XTRUCT, NULL);
   xtruct1->byte_thing = 1;