You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/09/01 20:26:27 UTC

git commit: THRIFT-2684 c_glib: Improvements to map deserialization in generated code

Repository: thrift
Updated Branches:
  refs/heads/master 546209c96 -> 008f42cb3


THRIFT-2684 c_glib: Improvements to map deserialization in generated code

Patch: Simon South


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/008f42cb
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/008f42cb
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/008f42cb

Branch: refs/heads/master
Commit: 008f42cb3846fdfbcdc85acfe129680fd51c2def
Parents: 546209c
Author: Roger Meier <ro...@apache.org>
Authored: Mon Sep 1 20:26:01 2014 +0200
Committer: Roger Meier <ro...@apache.org>
Committed: Mon Sep 1 20:26:01 2014 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_c_glib_generator.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/008f42cb/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 61a5461..050463f 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -3423,8 +3423,11 @@ void t_c_glib_generator::declare_local_variable(ofstream &out, t_type *ttype, st
   string ptr = ttype->is_string() || !ttype->is_base_type() ? "" : "*";
 
   if (ttype->is_map()) {
+    t_map *tmap = (t_map *)ttype;
     out <<
-    indent() << tname << ptr << " " << name << " = g_hash_table_new (NULL, NULL);" << endl;
+      indent() << tname << ptr << " " << name << " = " <<
+      generate_new_hash_from_type(tmap->get_key_type(), tmap->get_val_type()) <<
+      endl;
   } else if (ttype->is_enum()) {
     out <<
     indent() << tname << ptr << " " << name << ";" << endl;
@@ -3540,7 +3543,7 @@ string t_c_glib_generator::generate_free_func_from_type (t_type * ttype) {
       case t_base_type::TYPE_I32:
       case t_base_type::TYPE_I64:
       case t_base_type::TYPE_DOUBLE:
-        return "NULL";
+        return "g_free";
       case t_base_type::TYPE_STRING:
         if (((t_base_type *) ttype)->is_binary()) {
             return "thrift_string_free";
@@ -3649,7 +3652,7 @@ string t_c_glib_generator::generate_cmp_func_from_type (t_type * ttype) {
         throw "compiler error: no hash table info for type";
     }
   } else if (ttype->is_enum()) {
-    return "NULL";
+    return "g_direct_equal";
   } else if (ttype->is_container() || ttype->is_struct()) {
     return "g_direct_equal";
   } else if (ttype->is_typedef()) {