diff options
Diffstat (limited to 'source/blender/makesdna/intern/dna_genfile.c')
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index fa5a55ef1b9..2e89629b05e 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -224,7 +224,7 @@ static void printstruct(SDNA *sdna, short strnr) */ int DNA_struct_find_nr_ex(const SDNA *sdna, const char *str, unsigned int *index_last) { - if (*index_last < sdna->nr_structs) { + if (*index_last < sdna->structs_len) { const short *sp = sdna->structs[*index_last]; if (STREQ(sdna->types[sp[0]], str)) { return *index_last; @@ -242,7 +242,7 @@ int DNA_struct_find_nr_ex(const SDNA *sdna, const char *str, unsigned int *index } #else { - for (int index = 0; index < sdna->nr_structs; index++) { + for (int index = 0; index < sdna->structs_len; index++) { const short *sp = sdna->structs[index]; if (STREQ(sdna->types[sp[0]], str)) { *index_last = index; @@ -304,14 +304,14 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error if (*data == MAKE_ID('N', 'A', 'M', 'E')) { data++; - sdna->nr_names = *data; + sdna->names_len = *data; if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->nr_names); + BLI_endian_switch_int32(&sdna->names_len); } - sdna->nr_names_alloc = sdna->nr_names; + sdna->names_len_alloc = sdna->names_len; data++; - sdna->names = MEM_callocN(sizeof(void *) * sdna->nr_names, "sdnanames"); + sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames"); } else { *r_error_message = "NAME error in SDNA file"; @@ -319,7 +319,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error } cp = (char *)data; - for (int nr = 0; nr < sdna->nr_names; nr++) { + for (int nr = 0; nr < sdna->names_len; nr++) { sdna->names[nr] = cp; /* "float gravity [3]" was parsed wrong giving both "gravity" and @@ -344,13 +344,13 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error if (*data == MAKE_ID('T', 'Y', 'P', 'E')) { data++; - sdna->nr_types = *data; + sdna->types_len = *data; if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->nr_types); + BLI_endian_switch_int32(&sdna->types_len); } data++; - sdna->types = MEM_callocN(sizeof(void *) * sdna->nr_types, "sdnatypes"); + sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes"); } else { *r_error_message = "TYPE error in SDNA file"; @@ -358,7 +358,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error } cp = (char *)data; - for (int nr = 0; nr < sdna->nr_types; nr++) { + for (int nr = 0; nr < sdna->types_len; nr++) { /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */ sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp); while (*cp) { @@ -377,17 +377,17 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error sdna->types_size = sp; if (do_endian_swap) { - BLI_endian_switch_int16_array(sp, sdna->nr_types); + BLI_endian_switch_int16_array(sp, sdna->types_len); } - sp += sdna->nr_types; + sp += sdna->types_len; } else { *r_error_message = "TLEN error in SDNA file"; return false; } /* prevent BUS error */ - if (sdna->nr_types & 1) { + if (sdna->types_len & 1) { sp++; } @@ -396,13 +396,13 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error if (*data == MAKE_ID('S', 'T', 'R', 'C')) { data++; - sdna->nr_structs = *data; + sdna->structs_len = *data; if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->nr_structs); + BLI_endian_switch_int32(&sdna->structs_len); } data++; - sdna->structs = MEM_callocN(sizeof(void *) * sdna->nr_structs, "sdnastrcs"); + sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs"); } else { *r_error_message = "STRC error in SDNA file"; @@ -410,7 +410,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error } sp = (short *)data; - for (int nr = 0; nr < sdna->nr_structs; nr++) { + for (int nr = 0; nr < sdna->structs_len; nr++) { sdna->structs[nr] = sp; if (do_endian_swap) { @@ -436,7 +436,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error { /* second part of gravity problem, setting "gravity" type to void */ if (gravity_fix > -1) { - for (int nr = 0; nr < sdna->nr_structs; nr++) { + for (int nr = 0; nr < sdna->structs_len; nr++) { sp = sdna->structs[nr]; if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) { sp[10] = SDNA_TYPE_VOID; @@ -448,9 +448,9 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error #ifdef WITH_DNA_GHASH { /* create a ghash lookup to speed up */ - sdna->structs_map = BLI_ghash_str_new_ex("init_structDNA gh", sdna->nr_structs); + sdna->structs_map = BLI_ghash_str_new_ex("init_structDNA gh", sdna->structs_len); - for (intptr_t nr = 0; nr < sdna->nr_structs; nr++) { + for (intptr_t nr = 0; nr < sdna->structs_len; nr++) { sp = sdna->structs[nr]; BLI_ghash_insert(sdna->structs_map, (void *)sdna->types[sp[0]], POINTER_FROM_INT(nr)); } @@ -482,8 +482,8 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error /* Cache name size. */ { - short *names_array_len = MEM_mallocN(sizeof(*names_array_len) * sdna->nr_names, __func__); - for (int i = 0; i < sdna->nr_names; i++) { + short *names_array_len = MEM_mallocN(sizeof(*names_array_len) * sdna->names_len, __func__); + for (int i = 0; i < sdna->names_len; i++) { names_array_len[i] = DNA_elem_array_size(sdna->names[i]); } sdna->names_array_len = names_array_len; @@ -573,7 +573,7 @@ static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structn sp = sdna->structs[structnr]; typenr = sp[0]; - for (a = 0; a < sdna->nr_structs; a++) { + for (a = 0; a < sdna->structs_len; a++) { if ((a != structnr) && (compflags[a] == SDNA_CMP_EQUAL)) { sp = sdna->structs[a]; elems = sp[1]; @@ -602,19 +602,19 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna const char *str1, *str2; char *compflags; - if (oldsdna->nr_structs == 0) { + if (oldsdna->structs_len == 0) { printf("error: file without SDNA\n"); return NULL; } - compflags = MEM_callocN(oldsdna->nr_structs, "compflags"); + compflags = MEM_callocN(oldsdna->structs_len, "compflags"); /* we check all structs in 'oldsdna' and compare them with * the structs in 'newsdna' */ unsigned int newsdna_index_last = 0; - for (a = 0; a < oldsdna->nr_structs; a++) { + for (a = 0; a < oldsdna->structs_len; a++) { sp_old = oldsdna->structs[a]; /* search for type in cur */ @@ -678,14 +678,14 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna /* Because structs can be inside structs, we recursively * set flags when a struct is altered */ - for (a = 0; a < oldsdna->nr_structs; a++) { + for (a = 0; a < oldsdna->structs_len; a++) { if (compflags[a] == SDNA_CMP_NOT_EQUAL) { recurs_test_compflags(oldsdna, compflags, a); } } #if 0 - for (a = 0; a < oldsdna->nr_structs; a++) { + for (a = 0; a < oldsdna->structs_len; a++) { if (compflags[a] == SDNA_CMP_NOT_EQUAL) { spold = oldsdna->structs[a]; printf("changed: %s\n", oldsdna->types[spold[0]]); @@ -1470,14 +1470,14 @@ static bool DNA_sdna_patch_struct_member_nr(SDNA *sdna, strlen(elem_old_full), elem_old_full_offset_start); - if (sdna->nr_names == sdna->nr_names_alloc) { - sdna->nr_names_alloc += 64; - sdna->names = MEM_recallocN(sdna->names, sizeof(*sdna->names) * sdna->nr_names_alloc); + if (sdna->names_len == sdna->names_len_alloc) { + sdna->names_len_alloc += 64; + sdna->names = MEM_recallocN(sdna->names, sizeof(*sdna->names) * sdna->names_len_alloc); sdna->names_array_len = MEM_recallocN( - (void *)sdna->names_array_len, sizeof(*sdna->names_array_len) * sdna->nr_names_alloc); + (void *)sdna->names_array_len, sizeof(*sdna->names_array_len) * sdna->names_len_alloc); } const short name_nr_prev = sp[1]; - sp[1] = sdna->nr_names++; + sp[1] = sdna->names_len++; sdna->names[sp[1]] = elem_new_full; sdna->names_array_len[sp[1]] = sdna->names_array_len[name_nr_prev]; @@ -1520,14 +1520,14 @@ bool DNA_sdna_patch_struct_member(SDNA *sdna, static void sdna_expand_names(SDNA *sdna) { int names_expand_len = 0; - for (int struct_nr = 0; struct_nr < sdna->nr_structs; struct_nr++) { + for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { const short *sp = sdna->structs[struct_nr]; names_expand_len += sp[1]; } const char **names_expand = MEM_mallocN(sizeof(*names_expand) * names_expand_len, __func__); int names_expand_index = 0; - for (int struct_nr = 0; struct_nr < sdna->nr_structs; struct_nr++) { + for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { /* We can't edit this memory 'sdna->structs' points to (readonly datatoc file). */ const short *sp = sdna->structs[struct_nr]; short *sp_expand = BLI_memarena_alloc(sdna->mem_arena, sizeof(short[2]) * (1 + sp[1])); @@ -1545,7 +1545,7 @@ static void sdna_expand_names(SDNA *sdna) } MEM_freeN((void *)sdna->names); sdna->names = names_expand; - sdna->nr_names = names_expand_len; + sdna->names_len = names_expand_len; } static const char *dna_sdna_alias_alias_from_static_elem_full(SDNA *sdna, @@ -1587,8 +1587,8 @@ void DNA_sdna_alias_data_ensure(SDNA *sdna) DNA_RENAME_ALIAS_FROM_STATIC, &struct_map_alias_from_static, &elem_map_alias_from_static); if (sdna->alias.types == NULL) { - sdna->alias.types = MEM_mallocN(sizeof(*sdna->alias.types) * sdna->nr_types, __func__); - for (int type_nr = 0; type_nr < sdna->nr_types; type_nr++) { + sdna->alias.types = MEM_mallocN(sizeof(*sdna->alias.types) * sdna->types_len, __func__); + for (int type_nr = 0; type_nr < sdna->types_len; type_nr++) { const char *struct_name_static = sdna->types[type_nr]; if (use_legacy_hack) { @@ -1602,8 +1602,8 @@ void DNA_sdna_alias_data_ensure(SDNA *sdna) if (sdna->alias.names == NULL) { sdna_expand_names(sdna); - sdna->alias.names = MEM_mallocN(sizeof(*sdna->alias.names) * sdna->nr_names, __func__); - for (int struct_nr = 0; struct_nr < sdna->nr_structs; struct_nr++) { + sdna->alias.names = MEM_mallocN(sizeof(*sdna->alias.names) * sdna->names_len, __func__); + for (int struct_nr = 0; struct_nr < sdna->structs_len; struct_nr++) { const short *sp = sdna->structs[struct_nr]; const char *struct_name_static = sdna->types[sp[0]]; |