On Thu, Apr 19, 2012 at 04:24:35PM +0300, Zeeshan Ali (Khattak) wrote: > On Thu, Apr 19, 2012 at 11:52 AM, Christophe Fergeau > <cfergeau@xxxxxxxxxx> wrote: > > On Thu, Apr 19, 2012 at 03:12:01AM +0300, Zeeshan Ali (Khattak) wrote: > >> From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx> > >> +static void > >> +gvir_domain_get_info_helper(GSimpleAsyncResult *res, > >> + GObject *object, > >> + GCancellable *cancellable G_GNUC_UNUSED) > >> +{ > >> + GVirDomain *dom = GVIR_DOMAIN(object); > >> + GVirDomainInfo *info; > >> + GError *err = NULL; > >> + > >> + info = gvir_domain_get_info(dom, &err); > >> + if (err) > >> + g_simple_async_result_take_error(res, err); > >> + else > >> + g_simple_async_result_set_op_res_gpointer(res, info, NULL); > > > > Shouldn't the last parameter be gvir_domain_info_free? > > No, we give this info to user in the finalize call: Looking at GSimpleAsyncResult documentation and use, it seems customary to pass a GDestroyNotify function here, and to ref the returned object in the _finish function if needed. It seems it's perfectly valid to call gvir_domain_get_info_async() with a NULL callback, or not to call _finish if you are not interested in the result. If you don't pass a non-NULL GDestroyNotify to set_op_res_gpointer, I don't see how you can avoid a memory leak in these cases. Think also of an error (cancellation) occurring between the call to _helper and the call to finish. Christophe
Attachment:
pgp_NOV1m7PCc.pgp
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list