diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-02 02:39:34 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-02 02:39:34 +0400 |
commit | 3bbf11761a78e45be465f7ebb3a7e4dfc1f9b13b (patch) | |
tree | 0a2a627478e9259956ac16ee8a69cd13ff013c41 /source/blender/blenlib/BLI_utildefines.h | |
parent | d7e835684687770bafe3584b6a2485d692deeb15 (diff) |
make rna layer access less cryptic by using ARRAY_HAS_ITEM(), modified this to use unsigned offset.
Diffstat (limited to 'source/blender/blenlib/BLI_utildefines.h')
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 5a104013803..bd6057f8b8f 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -300,13 +300,12 @@ typedef bool _BLI_Bool; #define UNPACK4OP(op, a) op((a)[0]), op((a)[1]), op((a)[2]), op((a)[3]) /* array helpers */ -#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \ +#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \ (arr_dtype *)((char *)arr_start + (elem_size * (tot - 1))) -#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ( \ - (item >= arr_start) && \ - (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)) \ - ) +#define ARRAY_HAS_ITEM(arr_item, arr_start, tot) \ + ((unsigned int)((arr_item) - (arr_start)) < (unsigned int)(tot)) + /* Warning-free macros for storing ints in pointers. Use these _only_ * for storing an int in a pointer, not a pointer in an int (64bit)! */ |