-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve exception safety with smart pointers #598
Comments
no thanks, this will add extra complication to the library, and the library itself tracks the ownership of the pointers (and owns all pointers). |
💭 Would you become interested to apply C++ Core Guidelines for any more software components? |
💭 How does such a feedback fit to improvable source code places? Example: Line 103 in d4b74da
|
there really is no need for this to be a smart pointer, it is just added complexity. Its lifetime is managed by its owning class. |
💭 Are smart pointers provided for the avoidance of undesirable software behaviour? 👀 Where do you see owning objects for the pointers “etf” and “zlib”? |
the one that creates them, discordclient :) This is the only place they are instantiated. |
I know. I interpret the linked source code in the way that the two pointer member variables “etf” and “zlib” are not initialised with “ |
👀 Would you like to take another look at the advice “Item 10: Prevent resource leaks in constructors.”? |
changing everything to smart pointers is a potentially lazy option, the correct fix is shown here without needing to add complexity to the library. We simply need to ensure that nullptr is set for those two values, and rethrow the std::bad_alloc after any cleanup. This is a much simpler change than refactoring an entire stable library (where a bad_alloc on construction of a discordclient has never happened in production in a real world system to our knowledge) to use unique_ptr. |
💭 Would you like to wrap any pointer data members with the class template “std::unique_ptr”?
The text was updated successfully, but these errors were encountered: