vector trxn.token

This commit is contained in:
David Parkhurst 2021-03-16 13:19:51 -06:00
parent 83cfb298d6
commit 7d303de1b4
8 changed files with 19 additions and 53 deletions

View File

@ -763,7 +763,6 @@ void Phreeqc::init(void)
* Reaction work space
*---------------------------------------------------------------------- */
// struct trxn;
trxn.token = 0;
for (int i = 0; i < MAX_LOG_K_INDICES; i++)
{
trxn.logk[i] = 0;
@ -773,7 +772,6 @@ void Phreeqc::init(void)
trxn.dz[i] = 0;
}
count_trxn = 0;
max_trxn = MAX_TRXN;
mb_unknowns = NULL;
count_mb_unknowns = 0;
@ -1896,7 +1894,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
trxn.dz[i] = 0;
}
count_trxn = 0;
max_trxn = MAX_TRXN;
*/
/*
mb_unknowns = NULL;

View File

@ -1531,7 +1531,6 @@ protected:
struct reaction_temp trxn; /* structure array of working space while reading equations
species names are in "temp_strings" */
int count_trxn; /* number of reactants in trxn = position of next */
int max_trxn;
struct unknown_list *mb_unknowns;
int count_mb_unknowns;

View File

@ -813,7 +813,7 @@ struct reaction_temp
{
LDBLE logk[MAX_LOG_K_INDICES];
LDBLE dz[3];
struct rxn_token_temp *token;
std::vector<struct rxn_token_temp> token;
};
struct rxn_token_temp
{ /* data for equations, aq. species or minerals */

View File

@ -78,10 +78,6 @@ initialize(void)
stag_data->exch_f = 0;
stag_data->th_m = 0;
stag_data->th_im = 0;
space((void **) ((void *) &trxn.token), INIT, &max_trxn,
sizeof(struct rxn_token_temp));
/*
* Create hash tables
*/

View File

@ -1025,11 +1025,8 @@ get_species(char **ptr)
char string[MAX_LENGTH];
int l;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t) count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
/* coefficient */
if (get_coef(&(trxn.token[count_trxn].coef), ptr) == ERROR)
{

View File

@ -2861,11 +2861,8 @@ add_potential_factor(void)
/*
* Make sure there is space
*/
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
/*
* Include psi in mass action equation
*/
@ -2958,11 +2955,8 @@ add_cd_music_factors(int n)
/*
* Make sure there is space
*/
if (count_trxn + 3 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 3, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 3 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 3);
/*
* Include psi in mass action equation
*/

View File

@ -291,10 +291,8 @@ clean_up(void)
change_surf = (struct Change_Surf *) free_check_null(change_surf);
/* miscellaneous work space */
//elt_list = (struct elt_list *) free_check_null(elt_list);
elt_list.clear();
trxn.token = (struct rxn_token_temp *) free_check_null(trxn.token);
trxn.token.clear();
mb_unknowns = (struct unknown_list *) free_check_null(mb_unknowns);
line = (char *) free_check_null(line);
line_save = (char *) free_check_null(line_save);
@ -2620,11 +2618,8 @@ trxn_add(cxxChemRxn &r_ptr, LDBLE coef, int combine)
*/
for (size_t j = 0; j < r_ptr.Get_tokens().size(); j++)
{
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
trxn.token[count_trxn].name = r_ptr.Get_tokens()[j].name;
trxn.token[count_trxn].s = r_ptr.Get_tokens()[j].s;
trxn.token[count_trxn].coef = coef * r_ptr.Get_tokens()[j].coef;
@ -2685,11 +2680,8 @@ trxn_add(struct reaction *r_ptr, LDBLE coef, int combine)
next_token = r_ptr->token;
while (next_token->s != NULL)
{
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
trxn.token[count_trxn].name = next_token->s->name;
trxn.token[count_trxn].s = next_token->s;
trxn.token[count_trxn].coef = coef * next_token->coef;
@ -2743,11 +2735,8 @@ trxn_add_phase(struct reaction *r_ptr, LDBLE coef, int combine)
next_token = r_ptr->token;
while (next_token->s != NULL || next_token->name != NULL)
{
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
if (next_token->s != NULL)
{
trxn.token[count_trxn].name = next_token->s->name;

View File

@ -2873,11 +2873,8 @@ species_rxn_to_trxn(struct species *s_ptr)
trxn.token[i].unknown = NULL;
trxn.token[i].coef = s_ptr->rxn->token[i].coef;
count_trxn = i + 1;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
}
return (OK);
}
@ -2916,11 +2913,8 @@ phase_rxn_to_trxn(struct phase *phase_ptr, struct reaction *rxn_ptr)
trxn.token[i].unknown = NULL;
trxn.token[i].coef = rxn_ptr->token[i].coef;
count_trxn = i + 1;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
}
return (OK);
}