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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-08-08 07:06:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-08 07:08:37 +0300
commita1d57e3f05f1602a07698e19f97f861d41f14775 (patch)
tree09d993cceed4d37c6d6a89ecd8aa764424aa0966 /source
parent171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 (diff)
Cleanup: replace sizeof division with ARRAY_SIZE macro
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/fluid.c5
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/unit.c2
-rw-r--r--source/blender/blenlib/intern/math_rotation.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_shader.c6
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp2
-rw-r--r--source/blender/freestyle/intern/stroke/ChainingIterators.cpp2
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c2
-rw-r--r--source/blender/imbuf/intern/filetype.c3
-rw-r--r--source/blender/makesrna/intern/makesrna.c2
10 files changed, 14 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index eb22c2a1462..ee7d85ba3fb 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1757,14 +1757,13 @@ static void update_distances(int index,
{0.0f, -1.0f, 1.0f}, {0.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, -1.0f, 1.0f},
{-1.0f, 1.0f, 1.0f}, {-1.0f, -1.0f, 1.0f}, {1.0f, 1.0f, -1.0f}, {1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}};
- size_t ray_cnt = sizeof ray_dirs / sizeof ray_dirs[0];
/* Count ray mesh misses (i.e. no face hit) and cases where the ray direction matches the face
* normal direction. From this information it can be derived whether a cell is inside or
* outside the mesh. */
int miss_cnt = 0, dir_cnt = 0;
- for (int i = 0; i < ray_cnt; i++) {
+ for (int i = 0; i < ARRAY_SIZE(ray_dirs); i++) {
BVHTreeRayHit hit_tree = {0};
hit_tree.index = -1;
hit_tree.dist = PHI_MAX;
@@ -1798,7 +1797,7 @@ static void update_distances(int index,
/* Point lies inside mesh. Use negative sign for distance value.
* This "if statement" has 2 conditions that can be true for points outside mesh. */
- if (!(miss_cnt > 0 || dir_cnt == ray_cnt)) {
+ if (!(miss_cnt > 0 || dir_cnt == ARRAY_SIZE(ray_dirs))) {
min_dist = (-1.0f) * fabsf(min_dist);
}
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index a7fdf93f656..94a142600b6 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -158,7 +158,7 @@ static AdrBit2Path ob_layer_bits[] = {
/* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */
#define RET_ABP(items) \
{ \
- *tot = sizeof(items) / sizeof(AdrBit2Path); \
+ *tot = ARRAY_SIZE(items); \
return items; \
} \
(void)0
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index b8d86f0dc5b..8414f93ddaa 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -130,7 +130,7 @@ typedef struct bUnitCollection {
/* Keep table lignment. */
/* clang-format off */
-#define UNIT_COLLECTION_LENGTH(def) (sizeof(def) / sizeof(bUnitDef) - 1)
+#define UNIT_COLLECTION_LENGTH(def) (ARRAY_SIZE(def) - 1)
#define NULL_UNIT {NULL, NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
/* Dummy */
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index a6368981050..d38c081ec2b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -2363,8 +2363,8 @@ bool mat3_from_axis_conversion(
value = ((src_forward << (0 * 3)) | (src_up << (1 * 3)) | (dst_forward << (2 * 3)) |
(dst_up << (3 * 3)));
- for (uint i = 0; i < (sizeof(_axis_convert_matrix) / sizeof(*_axis_convert_matrix)); i++) {
- for (uint j = 0; j < (sizeof(*_axis_convert_lut) / sizeof(*_axis_convert_lut[0])); j++) {
+ for (uint i = 0; i < (ARRAY_SIZE(_axis_convert_matrix)); i++) {
+ for (uint j = 0; j < (ARRAY_SIZE(*_axis_convert_lut)); j++) {
if (_axis_convert_lut[i][j] == value) {
copy_m3_m3(r_mat, _axis_convert_matrix[i]);
return true;
diff --git a/source/blender/draw/engines/workbench/workbench_shader.c b/source/blender/draw/engines/workbench/workbench_shader.c
index aab3cef00e6..9cc5087bd36 100644
--- a/source/blender/draw/engines/workbench/workbench_shader.c
+++ b/source/blender/draw/engines/workbench/workbench_shader.c
@@ -508,11 +508,11 @@ void workbench_shader_free(void)
struct GPUShader **sh_array = &e_data.transp_prepass_sh_cache[0][0][0][0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.opaque_composite_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.opaque_composite_sh); j++) {
struct GPUShader **sh_array = &e_data.opaque_composite_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.shadow_depth_pass_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.shadow_depth_pass_sh); j++) {
struct GPUShader **sh_array = &e_data.shadow_depth_pass_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
@@ -524,7 +524,7 @@ void workbench_shader_free(void)
struct GPUShader **sh_array = &e_data.cavity_sh[0][0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
- for (int j = 0; j < sizeof(e_data.smaa_sh) / sizeof(void *); j++) {
+ for (int j = 0; j < ARRAY_SIZE(e_data.smaa_sh); j++) {
struct GPUShader **sh_array = &e_data.smaa_sh[0];
DRW_SHADER_FREE_SAFE(sh_array[j]);
}
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 2b43e913b3d..388c2f35774 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -376,7 +376,7 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
{FREESTYLE_FE_EXTERNAL_CONTOUR, 0},
{FREESTYLE_FE_EDGE_MARK, 0},
};
- int num_edge_types = sizeof(conditions) / sizeof(struct edge_type_condition);
+ int num_edge_types = ARRAY_SIZE(conditions);
if (G.debug & G_DEBUG_FREESTYLE) {
cout << "Linesets:" << endl;
}
diff --git a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
index 271db48aabe..2b2ab0dc14a 100644
--- a/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
+++ b/source/blender/freestyle/intern/stroke/ChainingIterators.cpp
@@ -169,7 +169,7 @@ int ChainSilhouetteIterator::traverse(const AdjacencyIterator &ait)
Nature::VALLEY,
Nature::RIDGE,
};
- int numNatures = sizeof(natures) / sizeof(Nature::EdgeNature);
+ int numNatures = ARRAY_SIZE(natures);
for (int i = 0; i < numNatures; ++i) {
if (getCurrentEdge()->getNature() & natures[i]) {
int n = 0;
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 8acfc23439f..73003265d8d 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -207,7 +207,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->srcFormat = format_DPX;
dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB);
- size_t max_elements = sizeof(header.imageHeader.element) / sizeof(header.imageHeader.element[0]);
+ size_t max_elements = ARRAY_SIZE(header.imageHeader.element);
if (dpx->numElements == 0 || dpx->numElements >= max_elements) {
if (verbose) {
printf("DPX: Wrong number of elements: %d\n", dpx->numElements);
diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index 29430036182..5aa588da36d 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -224,8 +224,7 @@ const ImFileType IMB_FILE_TYPES[] = {
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0},
};
-const ImFileType *IMB_FILE_TYPES_LAST =
- &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1];
+const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[ARRAY_SIZE(IMB_FILE_TYPES) - 1];
void imb_filetypes_init(void)
{
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 8781a3f448f..779e4363be0 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3590,7 +3590,7 @@ static void rna_generate_struct_prototypes(FILE *f)
if (found == 0) {
fprintf(f, "struct %s;\n", struct_name);
- if (all_structures >= sizeof(structures) / sizeof(structures[0])) {
+ if (all_structures >= ARRAY_SIZE(structures)) {
printf("Array size to store all structures names is too small\n");
exit(1);
}