[Webkit-unassigned] [Bug 82082] [SOUP] Implement missing methods in CookieJarSoup

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 26 09:00:03 PDT 2012


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





--- Comment #8 from Carlos Garcia Campos <cgarcia at igalia.com>  2012-03-26 09:00:03 PST ---
(In reply to comment #7)
> (In reply to comment #5)
> 
> > what's is tricky exactly? soup_cookie_jar_all_cookies() returns a transfer full GSList, so we need a GOwnPtr for the container and another one for every item.
> 
> GOwnPtr is typically used for the entire lifetime of an object. In this case you are assigning a pre-existing objects to GOwnPtrs and they are freed almost as a side-effect of that.

I don't get what you mean, GOwnPtr always frees the pointer as a side-effect for me. We usually do something like

GOwnPtr<char> foo(g_strdup("Foo"));
use_foo (bar, foo.get());

and that's supposed to be fine. 

This is the same, we have a method that returns a new allocated list, which transfers the full list, container and contents, so you are expected to free it, the same way g_strdup() returns a new allocated string that you should free it when done. 

soup_cookies_free() is convenient method to free both the container and the contents. It iterates the list calling soup_cookie_free() for every item (like our GOwnPtr is doing) and then calls g_slist_free() (like our GOwnPtr does). 

When an object returns a transfer full list, you typically use g_list_free_full() or g_list_foreach() + g_list_free() when you are not iterating the list, but when you need to iterate the list, you can free every item when iterating and then free the list to avoid iterating the list twice. This second case is what the patch does.

-- 
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