diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-03-29 16:36:01 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-03-29 16:36:01 +0300 |
commit | 11130970c6a3ff14cb4dd0caece2137891b43e87 (patch) | |
tree | b21d79b38e4ee28ed9762973e8ea1cc604dcfd1b /source/blender/blenlib | |
parent | f6ad53804099802ab3f5eafa830f95f8545eb888 (diff) | |
parent | ca5f3dd2200725712a665705fc25e20a208d6295 (diff) |
Merge commit 'origin/master^' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_array_utils.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/array_utils.c | 17 |
2 files changed, 27 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_array_utils.h b/source/blender/blenlib/BLI_array_utils.h index a46c87cec40..9a510bcfc3b 100644 --- a/source/blender/blenlib/BLI_array_utils.h +++ b/source/blender/blenlib/BLI_array_utils.h @@ -74,10 +74,18 @@ bool _bli_array_iter_span( bool use_wrap, bool use_delimit_bounds, bool (*test_fn)(const void *arr_item, void *user_data), void *user_data, unsigned int span_step[2], unsigned int *r_span_len); -#define BLI_array_iter_span(arr, arr_len, use_wrap, use_delimit_bounds, test_fn, user_data, \ - span_step, r_span_len) \ +#define BLI_array_iter_span( \ + arr, arr_len, use_wrap, use_delimit_bounds, test_fn, user_data, \ + span_step, r_span_len) \ _bli_array_iter_span( \ arr, arr_len, sizeof(*(arr)), use_wrap, use_delimit_bounds, test_fn, user_data, \ span_step, r_span_len) +bool _bli_array_is_zeroed( + const void *arr, + unsigned int arr_len, size_t arr_stride); +#define BLI_array_is_zeroed(arr, arr_len) \ + _bli_array_is_zeroed( \ + arr, arr_len, sizeof(*(arr))) + #endif /* __BLI_ARRAY_UTILS_H__ */ diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c index 32f0111babd..7b2d35a763c 100644 --- a/source/blender/blenlib/intern/array_utils.c +++ b/source/blender/blenlib/intern/array_utils.c @@ -308,3 +308,20 @@ bool _bli_array_iter_span( return false; } + +/** + * Simple utility to check memory is zeroed. + */ +bool _bli_array_is_zeroed( + const void *arr_v, + unsigned int arr_len, size_t arr_stride) +{ + const char *arr_step = (const char *)arr_v; + size_t i = arr_stride * arr_len; + while (i--) { + if (*(arr_step++)) { + return false; + } + } + return true; +} |