Merge commit 'c1c08f2f2d4a08ec86b46d70716fb709eb863e9c'

This commit is contained in:
Darth Vader 2021-03-18 23:29:19 +00:00
commit b6a0f193c9
5 changed files with 26 additions and 30 deletions

View File

@ -966,13 +966,6 @@ void Phreeqc::init(void)
basic_callback_cookie = NULL;
basic_fortran_callback_ptr = NULL;
/* cl1.cpp ------------------------------- */
x_arg = NULL;
res_arg = NULL;
scratch = NULL;
x_arg_max = 0;
res_arg_max = 0;
scratch_max = 0;
#ifdef SKIP
/* dw.cpp ------------------------------- */
/* COMMON /QQQQ/ */

View File

@ -1737,9 +1737,7 @@ protected:
#endif
/* cl1.cpp ------------------------------- */
LDBLE *x_arg, *res_arg, *scratch;
std::vector<double> x_arg_v, res_arg_v, scratch_v;
int x_arg_max, res_arg_max, scratch_max;
std::vector<double> x_arg, res_arg, scratch;
/* gases.cpp ------------------------------- */
LDBLE a_aa_sum, b2, b_sum, R_TK;

View File

@ -2636,7 +2636,7 @@ edl_species(const char *surf_name, LDBLE * count, char ***names, LDBLE ** moles,
/*
* Sort system species
*/
if (sys.size() > 1)
if (sys.size() > 0)
{
qsort(&sys[0], sys.size(),
sizeof(struct system_species), system_species_compare);
@ -2727,12 +2727,12 @@ system_total(const char *total_name, LDBLE * count, char ***names,
/*
* Sort system species
*/
if (sys.size() > 1 && isort == 0)
if (sys.size() > 0 && isort == 0)
{
qsort(&sys[0], sys.size(),
sizeof(struct system_species), system_species_compare);
}
else
else if (sys.size() > 0)
{
qsort(&sys[0], sys.size(),
(size_t)sizeof(struct system_species), system_species_compare_name);

View File

@ -849,24 +849,31 @@ cl1(int k, int l, int m, int n,
void Phreeqc::
cl1_space(int check, int l_n2d, int klm, int l_nklmd)
{
if (l_n2d > x_arg_v.size())
if (check == 1)
{
x_arg_v.resize(l_n2d);
x_arg = &x_arg_v[0];
}
memset(&x_arg_v[0], 0, sizeof(double) * (size_t)l_n2d);
if ((size_t)l_n2d > x_arg.size())
{
x_arg.resize((size_t)l_n2d);
}
memset(&x_arg[0], 0, sizeof(double) * (size_t)l_n2d);
if (klm > res_arg_v.size())
{
res_arg_v.resize(klm);
res_arg = &res_arg_v[0];
if ((size_t)klm > res_arg.size())
{
res_arg.resize((size_t)klm);
}
memset(&res_arg[0], 0, sizeof(double) * (size_t)klm);
}
memset(&res_arg_v[0], 0, sizeof(double) * (size_t)klm);
if (l_nklmd > scratch_v.size())
if (l_nklmd > 0)
{
scratch_v.resize(l_nklmd);
scratch = &scratch_v[0];
if ((size_t)l_nklmd > scratch.size())
{
scratch.resize(l_nklmd);
}
memset(&scratch[0], 0, sizeof(double) * (size_t)l_nklmd);
}
else if (scratch.size() == 0)
{
scratch.resize(1);
memset(&scratch[0], 0, sizeof(double));
}
memset(&scratch_v[0], 0, sizeof(double) * (size_t)l_nklmd);
}

View File

@ -226,8 +226,6 @@ check_eqn(int association)
/*
* Sort elements in reaction and combine
*/
//qsort(elt_list[0], (size_t) count_elts, sizeof(struct elt_list),
// elt_list_compare);
if (elt_list_combine() == ERROR)
return (ERROR);
/*