[Webkit-unassigned] [Bug 33590] [GTK] GObject DOM bindings

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 1 06:05:52 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=33590





--- Comment #28 from Christian Dywan <christian at twotoasts.de>  2010-02-01 06:05:49 PST ---
(In reply to comment #27)
> (In reply to comment #26)
> > > +inline char * domStringConvert(WebCore::String const& s) { return g_strdup(s.utf8().data()); }
> > > +inline char * domStringConvert(WebCore::KURL const& s) { return g_strdup(s.string().utf8().data()); }
> > > +inline char * domStringConvert(const JSC::UString& s) { return g_strdup(s.UTF8String().c_str()); }
> > > +inline char * domStringConvert(WebCore::AtomicString const& s) { return g_strdup(s.string().utf8().data()); }
> > 
> > There’s some extra whitespace around the * on these lines.  g_strdup returns
> > gchar*.  Is there a reason the return types here are char* rather than gchar*? 
> > The latter seems to better communicate what type the strings are and how they
> > need to be disposed of.
> 
> gchar* and char* are exactly the same thing, one is just a typedef for the
> other. The functions return UTF8-encoded NULL-terminated char arrays, that need
> to be freed manually.

There is a subtle difference. g_strdup may be using a different memory
allocator, such as GSlice, as opposed to strdup. So using gchar* for the return
type makes it clear that g_free rather than free should be used to release the
memory.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list