Skip to contentSkip to conversation

CLD: remove g_list_foreach

PATCH In review Pete Zaitcev 1 participant 1 message Apr 18, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 4/12 CLD: remove g_list_foreach

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.

---
 lib/cldc.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

commit 1c32872b92911a1bbf48f8a9033569eb5ae33095

Author: Master <[email protected]>
Date:   Sat Apr 17 19:15:54 2010 -0600

Eshew g_list_foreach when changing the list.

lib/cldc.c +4 -6
index 6ab2fe4..8a238e4 100644
@@ -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);