Bug 20317
Summary: | [GTK] Add smart pointers for GTK use | ||
---|---|---|---|
Product: | WebKit | Reporter: | Marco Barisione <marco.barisione> |
Component: | WebKitGTK | Assignee: | Marco Barisione <marco.barisione> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Enhancement | CC: | jonathon |
Priority: | P2 | Keywords: | Gtk |
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
Marco Barisione
It would be useful to have some smart pointers to be used in the GTK port to reduce memory leaks and code complexity. We should need at least a OwnPtr-like class for pointers and a ref ptr for gobjects.
I can see two possibilities: modifying OwnPtr and RefPtr for our needs or add new classes. The first solution could be a bit tricky so I think we could add something like:
template <typename T, freeFunction=g_free> class GOwnPtr : Noncopyable { ... };
typedef GOwnPtr<gchar*> GCharPtr; // most of the times we are dealing with chars
template <typename T=GObject*> class GObjectPtr { ... };
What do you think? Before starting to write anything I would like to hear the opinion of people more expert than me on C++.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Marco Barisione
*** This bug has been marked as a duplicate of 20483 ***