Hi Andrei, On Thu, Nov 28, 2013, Andrei Emeltchenko wrote: > This cleans up rfsock structures closing all sockets and making general cleanup > for servers and for connections. This will be called form socket unregister. > --- > android/socket.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/android/socket.c b/android/socket.c > index 1fb154d..d55db54 100644 > --- a/android/socket.c > +++ b/android/socket.c > @@ -943,7 +943,27 @@ bool bt_socket_register(int sk, const bdaddr_t *addr) > return true; > } > > +static void free_connection(gpointer data, gpointer user_data) > +{ > + struct rfcomm_sock *rfsock = data; > + > + connections = g_list_remove(connections, rfsock); > + cleanup_rfsock(rfsock); > +} > + > +static void free_server(gpointer data, gpointer user_data) > +{ > + struct rfcomm_sock *rfsock = data; > + > + servers = g_list_remove(servers, rfsock); > + cleanup_rfsock(rfsock); > +} > + > void bt_socket_unregister(void) > { > DBG(""); > + > + g_list_foreach(connections, free_connection, NULL); > + > + g_list_foreach(servers, free_server, NULL); > } I think what you're looking for here is g_slist_free_full instead of g_slist_foreach. That way you won't need to have any helper functions at all but you can directly pass cleanup_rfsock to it. Johan -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html