[Bf-blender-cvs] [342593f1248] master: Cleanup: rename BLI_array_count -> len
Campbell Barton
noreply at git.blender.org
Wed Mar 14 15:46:51 CET 2018
Commit: 342593f1248c739a9f30c005ae710b9b9c7d0877
Author: Campbell Barton
Date: Thu Mar 15 01:42:44 2018 +1100
Branches: master
https://developer.blender.org/rB342593f1248c739a9f30c005ae710b9b9c7d0877
Cleanup: rename BLI_array_count -> len
Match naming convention used everywhere else.
Count should only be used when this isn't directly accessible.
===================================================================
M source/blender/blenlib/BLI_array.h
M source/blender/blenlib/intern/BLI_array.c
M source/blender/bmesh/intern/bmesh_core.c
M source/blender/bmesh/intern/bmesh_mods.c
M source/blender/bmesh/intern/bmesh_polygon_edgenet.c
M source/blender/bmesh/operators/bmo_dissolve.c
M source/blender/bmesh/operators/bmo_edgenet.c
M source/blender/bmesh/operators/bmo_subdivide.c
M source/blender/bmesh/tools/bmesh_bevel.c
M source/blender/editors/mesh/editmesh_knife.c
M source/blender/editors/mesh/editmesh_select.c
M source/blender/editors/object/object_vgroup.c
M source/blender/editors/space_node/node_templates.c
M source/blender/editors/uvedit/uvedit_ops.c
M source/blender/modifiers/intern/MOD_skin.c
===================================================================
diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h
index 825acb18e91..8e94b8197ef 100644
--- a/source/blender/blenlib/BLI_array.h
+++ b/source/blender/blenlib/BLI_array.h
@@ -62,9 +62,10 @@
* Doing the realloc in a macro isn't so simple,
* so use a function the macros can use.
*/
-void _bli_array_grow_func(void **arr_p, const void *arr_static,
- const int sizeof_arr_p, const int arr_count, const int num,
- const char *alloc_str);
+void _bli_array_grow_func(
+ void **arr_p, const void *arr_static,
+ const int sizeof_arr_p, const int arr_len, const int num,
+ const char *alloc_str);
/* -------------------------------------------------------------------- */
@@ -74,18 +75,18 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
/** use ``sizeof(*(arr))`` to ensure the array exists and is an array */
#define BLI_array_declare(arr) \
- int _##arr##_count = ((void)(sizeof(*(arr))), 0); \
+ int _##arr##_len = ((void)(sizeof(*(arr))), 0); \
void *_##arr##_static = NULL
/**
* this will use stack space, up to maxstatic array elements, before
* switching to dynamic heap allocation */
#define BLI_array_staticdeclare(arr, maxstatic) \
- int _##arr##_count = 0; \
+ int _##arr##_len = 0; \
char _##arr##_static[maxstatic * sizeof(*(arr))]
/** returns the logical size of the array, not including buffering. */
-#define BLI_array_count(arr) ((void)0, _##arr##_count)
+#define BLI_array_len(arr) ((void)0, _##arr##_len)
/**
* Grow the array by a fixed number of items.
@@ -95,23 +96,23 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
#define BLI_array_reserve(arr, num) (void)( \
(((void *)(arr) == NULL) && \
((void *)(_##arr##_static) != NULL) && \
- /* don't add _##arr##_count below because it must be zero */ \
- (_bli_array_totalsize_static(arr) >= _##arr##_count + (num))) ? \
+ /* don't add _##arr##_len below because it must be zero */ \
+ (_bli_array_totalsize_static(arr) >= _##arr##_len + (num))) ? \
/* we have an empty array and a static var big enough */ \
(void)(arr = (void *)_##arr##_static) \
: \
/* use existing static array or allocate */ \
- (LIKELY(_bli_array_totalsize(arr) >= _##arr##_count + (num)) ? \
+ (LIKELY(_bli_array_totalsize(arr) >= _##arr##_len + (num)) ? \
(void)0 /* do nothing */ : \
_bli_array_grow_func((void **)&(arr), _##arr##_static, \
- sizeof(*(arr)), _##arr##_count, num, \
+ sizeof(*(arr)), _##arr##_len, num, \
"BLI_array." #arr)) \
)
/** returns length of array */
#define BLI_array_grow_items(arr, num) \
- (BLI_array_reserve(arr, num), (_##arr##_count += num))
+ (BLI_array_reserve(arr, num), (_##arr##_len += num))
#define BLI_array_grow_one(arr) \
BLI_array_grow_items(arr, 1)
@@ -119,7 +120,7 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
/** appends an item to the array. */
#define BLI_array_append(arr, item) ( \
(void) BLI_array_grow_one(arr), \
- (void) (arr[_##arr##_count - 1] = item) \
+ (void) (arr[_##arr##_len - 1] = item) \
)
/**
@@ -127,13 +128,13 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
* item is not a pointer, but actual data value.*/
#define BLI_array_append_r(arr, item) ( \
(void) BLI_array_grow_one(arr), \
- (void) (arr[_##arr##_count - 1] = item), \
- (&arr[_##arr##_count - 1]) \
+ (void) (arr[_##arr##_len - 1] = item), \
+ (&arr[_##arr##_len - 1]) \
)
/** appends (grows) & returns a pointer to the uninitialized memory */
#define BLI_array_append_ret(arr) \
- (BLI_array_reserve(arr, 1), &arr[(_##arr##_count++)])
+ (BLI_array_reserve(arr, 1), &arr[(_##arr##_len++)])
#define BLI_array_free(arr) { \
if (arr && (char *)arr != _##arr##_static) { \
@@ -143,26 +144,26 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
} ((void)0)
#define BLI_array_pop(arr) ( \
- (arr && _##arr##_count) ? \
- arr[--_##arr##_count] : \
+ (arr && _##arr##_len) ? \
+ arr[--_##arr##_len] : \
NULL \
)
/**
- * resets the logical size of an array to zero, but doesn't
+ * Resets the logical size of an array to zero, but doesn't
* free the memory. */
#define BLI_array_clear(arr) \
- { _##arr##_count = 0; } (void)0
+ { _##arr##_len = 0; } ((void)0)
/**
- * set the count of the array, doesn't actually increase the allocated array
+ * Set the length of the array, doesn't actually increase the allocated array
* size. don't use this unless you know what you're doing. */
-#define BLI_array_count_set(arr, count) \
- { _##arr##_count = (count); }(void)0
+#define BLI_array_len_set(arr, len) \
+ { _##arr##_len = (len); } ((void)0)
/** only to prevent unused warnings */
#define BLI_array_fake_user(arr) \
- ((void)_##arr##_count, \
+ ((void)_##arr##_len, \
(void)_##arr##_static)
/** \} */
@@ -191,7 +192,7 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
#define BLI_array_fixedstack_free(arr) \
if (_##arr##_is_static) { \
MEM_freeN(arr); \
- } (void)0
+ } ((void)0)
/** \} */
diff --git a/source/blender/blenlib/intern/BLI_array.c b/source/blender/blenlib/intern/BLI_array.c
index f681d222e69..d16dd36763d 100644
--- a/source/blender/blenlib/intern/BLI_array.c
+++ b/source/blender/blenlib/intern/BLI_array.c
@@ -66,21 +66,23 @@
/**
* This function is only to be called via macros.
*
- * \note The caller must adjust \a arr_count
+ * \note The caller must adjust \a arr_len
*/
-void _bli_array_grow_func(void **arr_p, const void *arr_static,
- const int sizeof_arr_p, const int arr_count, const int num,
- const char *alloc_str)
+void _bli_array_grow_func(
+ void **arr_p, const void *arr_static,
+ const int sizeof_arr_p, const int arr_len, const int num,
+ const char *alloc_str)
{
void *arr = *arr_p;
void *arr_tmp;
- arr_tmp = MEM_mallocN(sizeof_arr_p *
- ((num < arr_count) ?
- (arr_count * 2 + 2) : (arr_count + num)), alloc_str);
+ arr_tmp = MEM_mallocN(
+ sizeof_arr_p *
+ ((num < arr_len) ?
+ (arr_len * 2 + 2) : (arr_len + num)), alloc_str);
if (arr) {
- memcpy(arr_tmp, arr, sizeof_arr_p * arr_count);
+ memcpy(arr_tmp, arr, sizeof_arr_p * arr_len);
if (arr != arr_static) {
MEM_freeN(arr);
@@ -91,6 +93,6 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
/* caller must do */
#if 0
- arr_count += num;
+ arr_len += num;
#endif
}
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index aba0160622f..c4b29e91fb4 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -1282,8 +1282,8 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del)
}
/* create region face */
- f_new = BLI_array_count(edges) ?
- BM_face_create_ngon(bm, v1, v2, edges, BLI_array_count(edges), faces[0], BM_CREATE_NOP) : NULL;
+ f_new = BLI_array_len(edges) ?
+ BM_face_create_ngon(bm, v1, v2, edges, BLI_array_len(edges), faces[0], BM_CREATE_NOP) : NULL;
if (UNLIKELY(f_new == NULL)) {
/* Invalid boundary region to join faces */
goto error;
@@ -1347,11 +1347,11 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del)
/* delete old geometry */
if (do_del) {
- for (i = 0; i < BLI_array_count(deledges); i++) {
+ for (i = 0; i < BLI_array_len(deledges); i++) {
BM_edge_kill(bm, deledges[i]);
}
- for (i = 0; i < BLI_array_count(delverts); i++) {
+ for (i = 0; i < BLI_array_len(delverts); i++) {
BM_vert_kill(bm, delverts[i]);
}
}
diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c
index 1cd51528e06..961cc458784 100644
--- a/source/blender/bmesh/intern/bmesh_mods.c
+++ b/source/blender/bmesh/intern/bmesh_mods.c
@@ -482,8 +482,8 @@ BMEdge *BM_vert_collapse_faces(
BLI_array_append(faces, f);
}
- if (BLI_array_count(faces) >= 2) {
- BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces), true);
+ if (BLI_array_len(faces) >= 2) {
+ BMFace *f2 = BM_faces_join(bm, faces, BLI_array_len(faces), t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list