X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=netlink.c;fp=netlink.c;h=3bc7d0160baf1341e959adaee4ed441b98ac0b68;hb=0781d5363fb6fd723a2316fc7558aef6439b2f71;hp=a04e6c9a42d9235c8520899b5cd14974ed9b4816;hpb=d6e2dbabccb08970da991e6d2b0fda7a56d83e6f;p=catta diff --git a/netlink.c b/netlink.c index a04e6c9..3bc7d01 100644 --- a/netlink.c +++ b/netlink.c @@ -12,9 +12,7 @@ struct _flxNetlink { GSource *source; void (*callback) (flxNetlink *nl, struct nlmsghdr *n, gpointer userdata); gpointer userdata; - GSourceFuncs source_funcs; }; - static gboolean work(flxNetlink *nl) { g_assert(nl); @@ -80,6 +78,15 @@ flxNetlink *flx_netlink_new(GMainContext *context, guint32 groups, void (*cb) (f struct sockaddr_nl addr; flxNetlink *nl; + static GSourceFuncs source_funcs = { + prepare_func, + check_func, + dispatch_func, + NULL, + NULL, + NULL + }; + g_assert(context); g_assert(cb); @@ -107,12 +114,7 @@ flxNetlink *flx_netlink_new(GMainContext *context, guint32 groups, void (*cb) (f nl->callback = cb; nl->userdata = userdata; - memset(&nl->source_funcs, 0, sizeof(nl->source_funcs)); - nl->source_funcs.prepare = prepare_func; - nl->source_funcs.check = check_func; - nl->source_funcs.dispatch = dispatch_func, - - nl->source = g_source_new(&nl->source_funcs, sizeof(GSource) + sizeof(flxNetlink*)); + nl->source = g_source_new(&source_funcs, sizeof(GSource) + sizeof(flxNetlink*)); *((flxNetlink**) (((guint8*) nl->source) + sizeof(GSource))) = nl; memset(&nl->poll_fd, 0, sizeof(GPollFD));