Cleanup: avoid using size for array length in naming
Confusing when array allocation takes two kinds of size arguments.
This commit is contained in:
parent
576142dc85
commit
5401fda412
@ -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;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user