GList and GSList data abstraction
- From: Kevin Lai <laik tnt stanford edu>
- To: gtk-devel-list redhat com
- Subject: GList and GSList data abstraction
- Date: Wed, 01 Mar 2000 18:26:03 -0800
There doesn't appear to be a way to access the data field of GList and
GSList without using g_list_nth_data() (which is overkill) or doing a
direct "list->data" (which violates data abstraction). The included
patch allows applications to avoid doing either by adding
g_list_data() and g_slist_data() macros.
On a related topic, perhaps g_list_nth_data() and g_slist_nth_data()
should be deleted because the equivalent functionality can be obtained
by using g_list_nth() and g_slist_nth().
Kevin
diff -u -r1.155 glib.h
--- glib.h 2000/03/01 09:44:09 1.155
+++ glib.h 2000/03/02 02:07:35
@@ -993,6 +993,7 @@
guint n);
#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
+#define g_list_data(list) ((list) ? (((GList *)(list))->data) : NULL)
/* Singly linked lists
@@ -1043,6 +1044,7 @@
gpointer g_slist_nth_data (GSList *list,
guint n);
#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
+#define g_slist_data(slist) ((slist) ? (((GSList *)(slist))->data) : NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]