thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zezeng Wang (Jira)" <>
Subject [jira] [Created] (THRIFT-5222) Manage memory with smart pointer
Date Sat, 30 May 2020 04:12:00 GMT
Zezeng Wang created THRIFT-5222:

             Summary: Manage memory with smart pointer
                 Key: THRIFT-5222
             Project: Thrift
          Issue Type: Improvement
          Components: C++ - Compiler, Compiler (General)
            Reporter: Zezeng Wang

Thrift 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);
  g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
  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;

This message was sent by Atlassian Jira

View raw message