summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-2-107
-rw-r--r--ChangeLog.pre-2-127
-rw-r--r--ChangeLog.pre-2-47
-rw-r--r--ChangeLog.pre-2-67
-rw-r--r--ChangeLog.pre-2-87
-rw-r--r--docs/reference/ChangeLog4
-rw-r--r--docs/reference/glib/glib-sections.txt1
-rw-r--r--glib/garray.c23
-rw-r--r--glib/garray.h3
-rw-r--r--tests/array-test.c13
11 files changed, 86 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f1899113..c48c0859c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 4f1899113..c48c0859c 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 4f1899113..c48c0859c 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 4f1899113..c48c0859c 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 4f1899113..c48c0859c 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 4f1899113..c48c0859c 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,10 @@
+Fri Dec 26 02:03:58 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/garray.[hc] (g_ptr_array_foreach): New function to
+ call a function for each element of a GPtrArray. (#114790)
+
+ * tests/array-test.c (main): Add a test for g_ptr_array_foreach().
+
Sun Dec 21 22:57:58 2003 Matthias Clasen <maclas@gmx.de>
* m4macros/glib-gettext.m4: Quote macro names to support
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index a197d764f..84e8aea05 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,7 @@
+Fri Dec 26 02:04:49 2003 Matthias Clasen <maclas@gmx.de>
+
+ * glib/glib-sections.txt: Add g_ptr_array_foreach().
+
Sun Dec 21 01:01:34 2003 Matthias Clasen <maclas@gmx.de>
* glib/tmpl/misc_utils.sgml: Document the encoding of
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index d72b76dd9..0f27726bf 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1638,6 +1638,7 @@ g_ptr_array_sort_with_data
g_ptr_array_set_size
g_ptr_array_index
g_ptr_array_free
+g_ptr_array_foreach
</SECTION>
diff --git a/glib/garray.c b/glib/garray.c
index e38a5a77c..21faff3a4 100644
--- a/glib/garray.c
+++ b/glib/garray.c
@@ -639,6 +639,29 @@ g_ptr_array_sort_with_data (GPtrArray *array,
user_data);
}
+/**
+ * g_ptr_array_foreach:
+ * @array: a #GPtrArray
+ * @func: the function to call for each array element
+ * @user_data: user data to pass to the function
+ *
+ * Calls a function for each element of a #GPtrArray.
+ *
+ * Since: 2.4
+ **/
+void
+g_ptr_array_foreach (GPtrArray *array,
+ GFunc func,
+ gpointer user_data)
+{
+ guint i;
+
+ g_return_if_fail (array);
+
+ for (i = 0; i < array->len; i++)
+ (*func) (array->pdata[i], user_data);
+}
+
/* Byte arrays
*/
diff --git a/glib/garray.h b/glib/garray.h
index b35d99ae7..e288a7296 100644
--- a/glib/garray.h
+++ b/glib/garray.h
@@ -126,6 +126,9 @@ void g_ptr_array_sort (GPtrArray *array,
void g_ptr_array_sort_with_data (GPtrArray *array,
GCompareDataFunc compare_func,
gpointer user_data);
+void g_ptr_array_foreach (GPtrArray *array,
+ GFunc func,
+ gpointer user_data);
/* Byte arrays, an array of guint8. Implemented as a GArray,
diff --git a/tests/array-test.c b/tests/array-test.c
index 4f187919b..6d4b5589b 100644
--- a/tests/array-test.c
+++ b/tests/array-test.c
@@ -57,6 +57,15 @@ typedef struct {
} GlibTestInfo;
+static void
+sum_up (gpointer data,
+ gpointer user_data)
+{
+ gint *sum = (gint *)user_data;
+
+ *sum += GPOINTER_TO_INT (data);
+}
+
int
main (int argc,
char *argv[])
@@ -65,6 +74,7 @@ main (int argc,
GArray *garray;
GPtrArray *gparray;
GByteArray *gbarray;
+ gint sum = 0;
/* array tests */
garray = g_array_new (FALSE, FALSE, sizeof (gint));
@@ -93,6 +103,9 @@ main (int argc,
for (i = 0; i < 10000; i++)
if (g_ptr_array_index (gparray, i) != GINT_TO_POINTER (i))
g_print ("array fails: %p ( %p )\n", g_ptr_array_index (gparray, i), GINT_TO_POINTER (i));
+
+ g_ptr_array_foreach (gparray, sum_up, &sum);
+ g_assert (sum == 49995000);
g_ptr_array_free (gparray, TRUE);