envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.8k stars 4.77k forks source link

Consistently use make_shared, make_unique utilities to avoid potential memory leaks #14044

Open nezdolik opened 3 years ago

nezdolik commented 3 years ago

Currently in code there is no consistent strategy for creating new objects wrapped into smart pointers. Is it recommended to use make_shared, make_unique utils to gracefully handle exceptions upon object construction: https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique

Example of code to be fixed: https://github.com/envoyproxy/envoy/blob/master/test/integration/clusters/custom_static_cluster.cc#L25

RuijingGuo commented 3 years ago

also we need to include shared_ptr