From: Pete Zaitcev Subject: [Patch 04/12] CLD: remove g_list_foreach Date: Sat, 17 Apr 2010 22:40:03 -0600 Message-ID: <20100417224003.511a3ed5@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: Sender: hail-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Jeff Garzik Cc: Project Hail List In practice this is not a bug, because g_list_foreach is implemented cleverly, and so the old code works. But it looks more direct with one less function, and we do not depend on g_list_foreach doing the right thing, since it's not in the documentation anywhere. Signed-off-by: Pete Zaitcev --- lib/cldc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) commit 1c32872b92911a1bbf48f8a9033569eb5ae33095 Author: Master Date: Sat Apr 17 19:15:54 2010 -0600 Eshew g_list_foreach when changing the list. diff --git a/lib/cldc.c b/lib/cldc.c index 6ab2fe4..8a238e4 100644 --- a/lib/cldc.c +++ b/lib/cldc.c @@ -2239,14 +2239,12 @@ void ncld_close(struct ncld_fh *fh) free(fh); } -static void ncld_func_close(gpointer data, gpointer priv) -{ - ncld_close(data); -} - void ncld_sess_close(struct ncld_sess *nsess) { - g_list_foreach(nsess->handles, ncld_func_close, NULL); + gpointer p; + + while ((p = g_list_nth_data(nsess->handles, 0))) + ncld_close(p); g_list_free(nsess->handles); cldc_kill_sess(nsess->udp->sess);