diff --git a/Phreeqc.cpp b/Phreeqc.cpp index 54bf7f4b..4236a163 100644 --- a/Phreeqc.cpp +++ b/Phreeqc.cpp @@ -978,9 +978,9 @@ void Phreeqc::init(void) /* ---------------------------------------------------------------------- * ISOTOPES * ---------------------------------------------------------------------- */ - count_master_isotope = 0; - master_isotope = NULL; - max_master_isotope = MAX_ELTS; + //count_master_isotope = 0; + //master_isotope = NULL; + //max_master_isotope = MAX_ELTS; initial_solution_isotopes = FALSE; calculate_value_hash_table = NULL; count_isotope_ratio = 0; @@ -2277,7 +2277,7 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc) max_master_isotope = MAX_ELTS; */ - for (int i = 0; i < pSrc->count_master_isotope; i++) + for (int i = 0; i < (int)pSrc->master_isotope.size(); i++) { struct master_isotope *master_isotope_ptr = master_isotope_store(pSrc->master_isotope[i]->name, FALSE); memcpy(master_isotope_ptr, pSrc->master_isotope[i], sizeof(struct master_isotope)); diff --git a/Phreeqc.h b/Phreeqc.h index 6562717e..a261d851 100644 --- a/Phreeqc.h +++ b/Phreeqc.h @@ -1727,9 +1727,10 @@ protected: * ---------------------------------------------------------------------- */ //struct name_coef match_tokens[50]; //int count_match_tokens; - int count_master_isotope; - struct master_isotope **master_isotope; - int max_master_isotope; + //int count_master_isotope; + //struct master_isotope **master_isotope; + //int max_master_isotope; + std::vector master_isotope; int initial_solution_isotopes; std::vector calculate_value; HashTable *calculate_value_hash_table; diff --git a/isotopes.cpp b/isotopes.cpp index 9e4f28ac..d6f30cba 100644 --- a/isotopes.cpp +++ b/isotopes.cpp @@ -478,7 +478,8 @@ add_isotopes(cxxSolution &solution_ref) /* * zero out isotopes */ - for (i = 0; i < count_master_isotope; i++) + //for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { master_isotope[i]->moles = 0; } @@ -513,7 +514,7 @@ add_isotopes(cxxSolution &solution_ref) * Set isotopes flag */ initial_solution_isotopes = FALSE; - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { if (master_isotope[i]->minor_isotope == TRUE && master_isotope[i]->moles > 0) @@ -662,7 +663,7 @@ calculate_isotope_moles(struct element *elt_ptr, /* * Update master_isotope */ - for (j = 0; j < count_master_isotope; j++) + for (j = 0; j < (int)master_isotope.size(); j++) { for (i = 0; i < count_isotopes; i++) { @@ -770,12 +771,12 @@ print_initial_solution_isotopes(void) print_centered("Isotopes"); output_msg(sformatf( "%10s\t%12s\t%12s\t%12s\t%12s\n\n", "Isotope", "Molality", "Moles", "Ratio", "Units")); - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { if (master_isotope[i]->minor_isotope == FALSE) { print_isotope = FALSE; - for (j = 0; j < count_master_isotope; j++) + for (j = 0; j < (int)master_isotope.size(); j++) { if ((master_isotope[j]->elt == master_isotope[i]->elt) && (master_isotope[j]->minor_isotope == TRUE) && @@ -794,7 +795,7 @@ print_initial_solution_isotopes(void) master_isotope[i]->name, (double) (master_isotope[i]->moles / mass_water_aq_x), (double) master_isotope[i]->moles)); - for (j = 0; j < count_master_isotope; j++) + for (j = 0; j < (int)master_isotope.size(); j++) { if (i == j) continue; @@ -991,7 +992,7 @@ print_isotope_ratios(void) * Print heading */ print_isotope = FALSE; - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { if (master_isotope[i]->minor_isotope == FALSE) continue; @@ -1053,7 +1054,7 @@ print_isotope_alphas(void) * Print heading */ print_isotope = FALSE; - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { if (master_isotope[i]->minor_isotope == FALSE) continue; @@ -1350,13 +1351,15 @@ master_isotope_store(const char *name, int replace_if_found) } else { - n = count_master_isotope++; - /* make sure there is space in s */ - if (count_master_isotope >= max_master_isotope) - { - space((void **) ((void *) &master_isotope), count_master_isotope, - &max_master_isotope, sizeof(struct master_isotope *)); - } + //n = count_master_isotope++; + ///* make sure there is space in s */ + //if (count_master_isotope >= max_master_isotope) + //{ + // space((void **) ((void *) &master_isotope), count_master_isotope, + // &max_master_isotope, sizeof(struct master_isotope *)); + //} + n = (int)master_isotope.size(); + master_isotope.resize((size_t)n + 1); /* Make new master_isotope structure */ master_isotope[n] = master_isotope_alloc(); master_isotope_ptr = master_isotope[n]; diff --git a/mainsubs.cpp b/mainsubs.cpp index 9df03df9..6e49dddd 100644 --- a/mainsubs.cpp +++ b/mainsubs.cpp @@ -98,14 +98,14 @@ initialize(void) space((void **) ((void *) &logk), INIT, &max_logk, sizeof(struct logk *)); - space((void **) ((void *) &master_isotope), INIT, &max_master_isotope, - sizeof(struct master_isotope *)); + //space((void **) ((void *) &master_isotope), INIT, &max_master_isotope, + // sizeof(struct master_isotope *)); /* * Create hash tables */ hcreate_multi((unsigned) max_logk, &logk_hash_table); - hcreate_multi((unsigned) max_master_isotope, &master_isotope_hash_table); + hcreate_multi((unsigned) MAX_ELTS, &master_isotope_hash_table); hcreate_multi((unsigned) max_elements, &elements_hash_table); hcreate_multi((unsigned) max_s, &species_hash_table); hcreate_multi((unsigned) max_phases, &phases_hash_table); @@ -1379,7 +1379,7 @@ xsolution_save(int n_user) */ if (initial_solution_isotopes == TRUE) { - for (int i = 0; i < count_master_isotope; i++) + for (int i = 0; i < (int)master_isotope.size(); i++) { if (master_isotope[i]->moles > 0) { diff --git a/structures.cpp b/structures.cpp index bef9008e..79d43539 100644 --- a/structures.cpp +++ b/structures.cpp @@ -225,13 +225,11 @@ clean_up(void) user_graph_headings = (char **) free_check_null(user_graph_headings); #endif /* master_isotope */ - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { - master_isotope[i] = - (struct master_isotope *) free_check_null(master_isotope[i]); + master_isotope[i] = (struct master_isotope *) free_check_null(master_isotope[i]); } - master_isotope = - (struct master_isotope **) free_check_null(master_isotope); + //master_isotope = (struct master_isotope **) free_check_null(master_isotope); hdestroy_multi(master_isotope_hash_table); master_isotope_hash_table = NULL; @@ -320,7 +318,7 @@ clean_up(void) count_phases = 0; count_s = 0; count_logk = 0; - count_master_isotope = 0; + //count_master_isotope = 0; count_rates = 0; count_inverse = 0; count_save_values = 0; diff --git a/tidy.cpp b/tidy.cpp index 665e8a5f..be3f71b3 100644 --- a/tidy.cpp +++ b/tidy.cpp @@ -5505,7 +5505,7 @@ tidy_master_isotope(void) int i; struct master *master_ptr; - for (i = 0; i < count_master_isotope; i++) + for (i = 0; i < (int)master_isotope.size(); i++) { /* * Mark master species list as minor isotope