diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-14 02:22:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-14 06:06:49 +0300 |
commit | 5401fda41244175b491ab5aad8c9693b3eb09f33 (patch) | |
tree | e21c91d18495431da34ab53779ed3f385bb2348a /source/blender | |
parent | 576142dc85c78ced792e3440a7665ea57e45a0cc (diff) |
Cleanup: avoid using size for array length in naming
Confusing when array allocation takes two kinds of size arguments.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_ccg.c | 19 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 10 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_solidify_nonmanifold.c | 14 |
3 files changed, 21 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index c7c77b83e25..77962ec924c 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -359,30 +359,29 @@ static void subdiv_ccg_init_faces(SubdivCCG *subdiv_ccg) /* TODO(sergey): Consider making it generic enough to be fit into BLI. */ typedef struct StaticOrHeapIntStorage { int static_storage[64]; - int static_storage_size; + int static_storage_len; int *heap_storage; - int heap_storage_size; + int heap_storage_len; } StaticOrHeapIntStorage; static void static_or_heap_storage_init(StaticOrHeapIntStorage *storage) { - storage->static_storage_size = sizeof(storage->static_storage) / - sizeof(*storage->static_storage); + storage->static_storage_len = sizeof(storage->static_storage) / sizeof(*storage->static_storage); storage->heap_storage = NULL; - storage->heap_storage_size = 0; + storage->heap_storage_len = 0; } -static int *static_or_heap_storage_get(StaticOrHeapIntStorage *storage, int size) +static int *static_or_heap_storage_get(StaticOrHeapIntStorage *storage, int heap_len) { /* Requested size small enough to be fit into stack allocated memory. */ - if (size <= storage->static_storage_size) { + if (heap_len <= storage->static_storage_len) { return storage->static_storage; } /* Make sure heap ius big enough. */ - if (size > storage->heap_storage_size) { + if (heap_len > storage->heap_storage_len) { MEM_SAFE_FREE(storage->heap_storage); - storage->heap_storage = MEM_malloc_arrayN(size, sizeof(int), "int storage"); - storage->heap_storage_size = size; + storage->heap_storage = MEM_malloc_arrayN(heap_len, sizeof(int), "int storage"); + storage->heap_storage_len = heap_len; } return storage->heap_storage; } diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index e5b2536f123..b753ab484af 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -153,18 +153,18 @@ static void version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data, IDProperty *default_value = IDP_GetPropertyFromGroup(prop_ui_data, "default"); if (default_value != NULL) { if (default_value->type == IDP_ARRAY) { - const int size = default_value->len; - ui_data->default_array_len = size; + const int array_len = default_value->len; + ui_data->default_array_len = array_len; if (default_value->subtype == IDP_FLOAT) { - ui_data->default_array = MEM_malloc_arrayN(size, sizeof(double), __func__); + ui_data->default_array = MEM_malloc_arrayN(array_len, sizeof(double), __func__); const float *old_default_array = IDP_Array(default_value); for (int i = 0; i < ui_data->default_array_len; i++) { ui_data->default_array[i] = (double)old_default_array[i]; } } else if (default_value->subtype == IDP_DOUBLE) { - ui_data->default_array = MEM_malloc_arrayN(size, sizeof(double), __func__); - memcpy(ui_data->default_array, IDP_Array(default_value), sizeof(double) * size); + ui_data->default_array = MEM_malloc_arrayN(array_len, sizeof(double), __func__); + memcpy(ui_data->default_array, IDP_Array(default_value), sizeof(double) * array_len); } } else if (ELEM(default_value->type, IDP_DOUBLE, IDP_FLOAT)) { diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c index f654b69841e..d4aaefcfe05 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c @@ -1168,9 +1168,9 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, add_index++; } if (last_split > split) { - const uint size = (split + edges_len) - (uint)last_split; + const uint edges_len_group = (split + edges_len) - (uint)last_split; NewEdgeRef **edges = MEM_malloc_arrayN( - size, sizeof(*edges), "edge_group split in solidify"); + edges_len_group, sizeof(*edges), "edge_group split in solidify"); memcpy(edges, g.edges + last_split, (edges_len - (uint)last_split) * sizeof(*edges)); @@ -1180,7 +1180,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, edge_groups[j + add_index] = (EdgeGroup){ .valid = true, .edges = edges, - .edges_len = size, + .edges_len = edges_len_group, .open_face_edge = MOD_SOLIDIFY_EMPTY_TAG, .is_orig_closed = g.is_orig_closed, .is_even_split = is_even_split, @@ -1193,14 +1193,14 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, }; } else { - const uint size = split - (uint)last_split; + const uint edges_len_group = split - (uint)last_split; NewEdgeRef **edges = MEM_malloc_arrayN( - size, sizeof(*edges), "edge_group split in solidify"); - memcpy(edges, g.edges + last_split, size * sizeof(*edges)); + edges_len_group, sizeof(*edges), "edge_group split in solidify"); + memcpy(edges, g.edges + last_split, edges_len_group * sizeof(*edges)); edge_groups[j + add_index] = (EdgeGroup){ .valid = true, .edges = edges, - .edges_len = size, + .edges_len = edges_len_group, .open_face_edge = MOD_SOLIDIFY_EMPTY_TAG, .is_orig_closed = g.is_orig_closed, .is_even_split = is_even_split, |