[webkit-help] WebKit2 Callback structs are leaked

Nick Guenther Nick.Guenther at dossierview.com
Thu Jan 27 10:25:57 PST 2011


Hello all,

I am experimenting with Webkit, trying to get it to do offscreen rendering. I have a small WinAPI C app that uses WebKit2. I notice that while there are Set*Client() methods, there don't seem to be any way to get your clients back out. So I have code like:

	WKPageLoaderClient *loader_callbacks = (WKPageLoaderClient*)malloc(sizeof(WKPageLoaderClient)); //FIXME: this leaks
	memset(loader_callbacks, 0, sizeof(WKPageLoaderClient));
	loader_callbacks->didFinishLoadForFrame = onLoad;

Which of course is in some function and ends up leaking loader_callbacks since that pointer is only kept around locally. The solution right now is to keep all my pointers around somewhere, or make the structs themselves global. But Globals Are Bad (TM), so for my future-curiosity I'm wondering if there plans to make Get*Client() methods or make WebKit2 free all the handlers? How is this supposed to be used?

Thanks in advance. Any insight would really clear things up for me.
-Nick Guenther
DossierView.com


More information about the webkit-help mailing list