[
https://issues.apache.org/jira/browse/THRIFT-5222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylwester Lachiewicz resolved THRIFT-5222.
------------------------------------------
Resolution: Fixed
Memory management moved to standard smart pointers:
{{std::shared_ptr}}/{{std::unique_ptr}} throughout lib/cpp (e.g.
[lib/cpp/src/thrift/transport/TBufferTransports.h|https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TBufferTransports.h],
[lib/cpp/src/thrift/concurrency/Mutex.h|https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/concurrency/Mutex.h])
since the C++11 rework. Resolving as Fixed.
> Manage memory with smart pointer
> --------------------------------
>
> Key: THRIFT-5222
> URL: https://issues.apache.org/jira/browse/THRIFT-5222
> Project: Thrift
> Issue Type: Improvement
> Components: C++ - Compiler, Compiler (General)
> Reporter: Zezeng Wang
> Priority: Major
>
> 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.
> {code:cpp}
> 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;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)