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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-08-17 09:56:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-08-17 10:02:20 +0400
commited26d9dd90cd67c0ee4d88e1b4da9f2e6ac963d0 (patch)
tree31555b40ba25a27421361289e68de3287f7528b8 /source/blender/blenlib/intern/BLI_array.c
parent1dd17bed4a7a322e6493914fee25ee9562e153ea (diff)
BLI_array: utility function for searching an array
Diffstat (limited to 'source/blender/blenlib/intern/BLI_array.c')
-rw-r--r--source/blender/blenlib/intern/BLI_array.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_array.c b/source/blender/blenlib/intern/BLI_array.c
index 21d7a5a6d10..da2eef8ab6a 100644
--- a/source/blender/blenlib/intern/BLI_array.c
+++ b/source/blender/blenlib/intern/BLI_array.c
@@ -137,3 +137,18 @@ void _bli_array_wrap(void *arr_v, unsigned int arr_len, size_t arr_stride, int d
BLI_assert(0);
}
}
+
+/**
+ * \note Not efficient, use for error checks/asserts.
+ */
+int _bli_array_findindex(const void *arr, unsigned int arr_len, size_t arr_stride, const void *p)
+{
+ const char *arr_step = (const char *)arr;
+ unsigned int i;
+ for (i = 0; i < arr_len; i++, arr_step += arr_stride) {
+ if (memcmp(arr_step, p, arr_stride) == 0) {
+ return (int)i;
+ }
+ }
+ return -1;
+}