[webkit-reviews] review requested: [Bug 20483] WebKit GTK Port needs a smartpointer to handle g_free (GFreePtr?) : [Attachment 24050] Add GOwnPtr

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Oct 3 07:17:41 PDT 2008

Marco Barisione <marco.barisione at collabora.co.uk> has asked  for review:
Bug 20483: WebKit GTK Port needs a smartpointer to handle g_free (GFreePtr?)

Attachment 24050: Add GOwnPtr

------- Additional Comments from Marco Barisione
<marco.barisione at collabora.co.uk>
This patch just adds GOwnPtr and converts just some small parts of the code to
use it, just for testing. When the patch is ready and committed I will post
another patch to add GRefPtr and the a patch to convert the existing code to
use them.

(In reply to comment #6)
> Why is it not possible to use OwnPtr for that? The windows platform can use
> for the various windows types.

Because they are different types from the ones used elsewhere in WebCore, while
GOwnPtr is for types that could be allocated both with new or g_malloc. For
instance the value held by GOwnPtr<gchar> (gchar is the same as char) will be
deleted with g_free, while the one held by OwnPtr<char> will be deleted with
Moreover, in the future we could want to add a way to use different free
functions, for instance if the data is allocated with the slice allocator
instead of the normal one.

> Why are you calling the destructor directly here?
> +    priv->~WebKitWebFramePrivate();

> And using placement new here?
> +    new(priv) WebKitWebFramePrivate;

The memory is allocated by glib with g_malloc but I still have to initialise
the struct to have the objects contained in it initialised and destroyed.

> (btw, we would normally put a space between new and ( -- at least that how
> every other placement new in WebCore that I have seen has been written)

I will fix it in the patch including this change.

More information about the webkit-reviews mailing list