summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/eina/eina_inarray.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/eina/eina_inarray.c b/src/lib/eina/eina_inarray.c
index 2d52e6fd34..a216f0291b 100644
--- a/src/lib/eina/eina_inarray.c
+++ b/src/lib/eina/eina_inarray.c
@@ -150,12 +150,23 @@ _eina_inarray_get(const Eina_Inarray *array, unsigned int position)
150static int 150static int
151_eina_inarray_search(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare) 151_eina_inarray_search(const Eina_Inarray *array, const void *data, Eina_Compare_Cb compare)
152{ 152{
153 const unsigned char *start, *found; 153 unsigned int found, pos=-1;
154 start = array->members; 154 void *p;
155 found = bsearch(data, start, array->len, array->member_size, compare); 155
156 if (!found) 156 if (array->len == 0)
157 return -1;
158
159 for (pos = 0; pos < array->len; ++pos)
160 {
161 p = _eina_inarray_get(array, pos);
162 found = compare(data, p);
163 if (found == 0)
164 break;
165 }
166 if (pos < array->len)
167 return pos;
168 else
157 return -1; 169 return -1;
158 return (found - start) / array->member_size;
159} 170}
160 171
161static unsigned int 172static unsigned int