Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5222

Manage memory with smart pointer

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Thrift's current allocate memory is still exist traditional manual new manual delete in most of the code,it will increase the probability of memory leak.

      Since thrift already adopt c++11, maybe use smart pointer is a better solution.

      void initGlobals() {
        g_type_void = new t_base_type("void", t_base_type::TYPE_VOID);
        g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
        g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
        ((t_base_type*)g_type_binary)->set_binary(true);
        g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
        ((t_base_type*)g_type_slist)->set_string_list(true);
        g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
        g_type_i8 = new t_base_type("i8", t_base_type::TYPE_I8);
        g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
        g_type_i32 = new t_base_type("i32", t_base_type::TYPE_I32);
        g_type_i64 = new t_base_type("i64", t_base_type::TYPE_I64);
        g_type_double = new t_base_type("double", t_base_type::TYPE_DOUBLE);
      }
      
      void clearGlobals() {
        delete g_type_void;
        delete g_type_string;
        delete g_type_bool;
        delete g_type_i8;
        delete g_type_i16;
        delete g_type_i32;
        delete g_type_i64;
        delete g_type_double;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zeshuai007 Zezeng Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: