Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2020-08-22 14:09:02 +0300
committerGitHub <noreply@github.com>2020-08-22 14:09:02 +0300
commit3cb098653b852f67c2a202e04b5f344bdd2d0ee8 (patch)
tree662b0af01368a63e82b2440b0bd9addb30adadb5
parent8afa37c663cfa9c72daaee95757ae2b030ec4b96 (diff)
[mono] Add g_ptr_array_find to eglib (#20279)
Co-authored-by: CoffeeFlux <CoffeeFlux@users.noreply.github.com>
-rw-r--r--mono/eglib/eglib-remap.h1
-rw-r--r--mono/eglib/glib.h1
-rw-r--r--mono/eglib/gptrarray.c15
3 files changed, 17 insertions, 0 deletions
diff --git a/mono/eglib/eglib-remap.h b/mono/eglib/eglib-remap.h
index c9751049c3b..6434803195e 100644
--- a/mono/eglib/eglib-remap.h
+++ b/mono/eglib/eglib-remap.h
@@ -159,6 +159,7 @@
#define g_ptr_array_sized_new monoeg_g_ptr_array_sized_new
#define g_ptr_array_sort monoeg_g_ptr_array_sort
#define g_ptr_array_sort_with_data monoeg_g_ptr_array_sort_with_data
+#define g_ptr_array_find monoeg_g_ptr_array_find
#define g_qsort_with_data monoeg_g_qsort_with_data
#define g_queue_free monoeg_g_queue_free
#define g_queue_is_empty monoeg_g_queue_is_empty
diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h
index 4272679aeb1..698ad614e4e 100644
--- a/mono/eglib/glib.h
+++ b/mono/eglib/glib.h
@@ -726,6 +726,7 @@ void g_ptr_array_set_size (GPtrArray *array, gint length);
gpointer *g_ptr_array_free (GPtrArray *array, gboolean free_seg);
void g_ptr_array_foreach (GPtrArray *array, GFunc func, gpointer user_data);
guint g_ptr_array_capacity (GPtrArray *array);
+gboolean g_ptr_array_find (GPtrArray *array, gconstpointer needle, guint *index);
#define g_ptr_array_index(array,index) (array)->pdata[(index)]
//FIXME previous missing parens
diff --git a/mono/eglib/gptrarray.c b/mono/eglib/gptrarray.c
index 09ea774d21c..18509bc4acc 100644
--- a/mono/eglib/gptrarray.c
+++ b/mono/eglib/gptrarray.c
@@ -229,3 +229,18 @@ g_ptr_array_capacity (GPtrArray *array)
{
return ((GPtrArrayPriv *)array)->size;
}
+
+gboolean
+g_ptr_array_find (GPtrArray *array, gconstpointer needle, guint *index)
+{
+ g_assert (array);
+ for (int i = 0; i < array->len; i++) {
+ if (array->pdata [i] == needle) {
+ if (index)
+ *index = i;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}