From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx> We create struct and a free function each time we need to pass a simple unsigned integer to an async function. Code can be simplified if we don't do that but rather use glib's API to convert to/from uint to pointer. This patch only changes this for one of these functions. I'll change other functions when/if there is a consensus on this.. --- libvirt-gobject/libvirt-gobject-domain.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index d6d804d..0289915 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -345,27 +345,18 @@ gboolean gvir_domain_start(GVirDomain *dom, return TRUE; } -typedef struct { - guint flags; -} DomainStartData; - -static void domain_start_data_free(DomainStartData *data) -{ - g_slice_free(DomainStartData, data); -} - static void gvir_domain_start_helper(GSimpleAsyncResult *res, GObject *object, GCancellable *cancellable G_GNUC_UNUSED) { GVirDomain *dom = GVIR_DOMAIN(object); - DomainStartData *data; GError *err = NULL; + guint flags; - data = g_simple_async_result_get_op_res_gpointer(res); + flags = GPOINTER_TO_UINT(g_simple_async_result_get_op_res_gpointer(res)); - if (!gvir_domain_start(dom, data->flags, &err)) + if (!gvir_domain_start(dom, flags, &err)) g_simple_async_result_take_error(res, err); } @@ -386,19 +377,17 @@ void gvir_domain_start_async(GVirDomain *dom, gpointer user_data) { GSimpleAsyncResult *res; - DomainStartData *data; g_return_if_fail(GVIR_IS_DOMAIN(dom)); g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable)); - data = g_slice_new0(DomainStartData); - data->flags = flags; - res = g_simple_async_result_new(G_OBJECT(dom), callback, user_data, gvir_domain_start_async); - g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)domain_start_data_free); + g_simple_async_result_set_op_res_gpointer (res, + GUINT_TO_POINTER(flags), + NULL); g_simple_async_result_run_in_thread(res, gvir_domain_start_helper, G_PRIORITY_DEFAULT, -- 1.7.11.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list