I just came in a C ++ SDK that is actually a strange * new
pattern I do not understand why they do so.
On the issue of the creation of objects * New, e.g. widgets wag = * new widget ();
?
Update: Interesting, they are actually XPtr & lt; T & gt; P = * new t;
- Some smart pointers should be magic terminology. Still does not matter much I believe SDK is of high quality.
This creates a new object and then its copy the original object The indicator is discarded, so a memory leak can occur.
The memory leak is not essentially , though it may be that the widget
keeps a list of all its examples, and that is the constructor and Updating that list in the district may be another way to obtain the contents of the list.
But it seems that it is useless instead. The reason for this probably was because of the misunderstanding that how the code actually works. To know how your code has been written, it is best to ask them as well. Clues in the comments of the code can you reveal more specific information about the code you are viewing?
Comments
Post a Comment