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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-06-27 16:59:01 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-06-27 16:59:01 +0300
commitcbce7fef1604fdfd3099fd196b2a44f61b22eb76 (patch)
treeb11963a42641ef95c61c01a7b2b83dddce4cd1a2 /source/blender/blenlib/intern/array_utils.c
parentc2dc77983dc4d3271858737a15ee058ef48fb833 (diff)
parente2c7ee773311734450a229051673fbfea61b641a (diff)
Merge branch 'master' into blender2.8
Conflicts: source/blender/blenkernel/intern/pointcache.c source/blender/makesrna/intern/rna_main_api.c source/blender/makesrna/intern/rna_particle.c
Diffstat (limited to 'source/blender/blenlib/intern/array_utils.c')
-rw-r--r--source/blender/blenlib/intern/array_utils.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index 9c91da4abee..32f0111babd 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -134,8 +134,22 @@ void _bli_array_permute(
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) {
+ for (unsigned int i = 0; i < arr_len; i++, arr_step += arr_stride) {
+ if (memcmp(arr_step, p, arr_stride) == 0) {
+ return (int)i;
+ }
+ }
+ return -1;
+}
+
+/**
+ * A version of #BLI_array_findindex that searches from the end of the list.
+ */
+int _bli_array_rfindindex(const void *arr, unsigned int arr_len, size_t arr_stride, const void *p)
+{
+ const char *arr_step = (const char *)arr + (arr_stride * arr_len);
+ for (unsigned int i = arr_len; i-- != 0; ) {
+ arr_step -= arr_stride;
if (memcmp(arr_step, p, arr_stride) == 0) {
return (int)i;
}