made tally_table a vector of class tally

This commit is contained in:
David Parkhurst 2021-04-26 23:38:21 -06:00
parent 0d764e5c0c
commit db31383e9a
3 changed files with 15 additions and 12 deletions

View File

@ -1109,7 +1109,7 @@ void Phreeqc::init(void)
/* tally.cpp ------------------------------- */
t_buffer = NULL;
tally_count_component = 0;
tally_table = NULL;
//tally_table = NULL;
count_tally_table_columns = 0;
count_tally_table_rows = 0;
/* transport.cpp ------------------------------- */

View File

@ -1769,7 +1769,8 @@ protected:
/* tally.cpp ------------------------------- */
class tally_buffer* t_buffer;
size_t tally_count_component;
class tally* tally_table;
//class tally* tally_table;
std::vector<class tally> tally_table;
size_t count_tally_table_columns;
size_t count_tally_table_rows;

View File

@ -172,7 +172,8 @@ store_tally_table(LDBLE * l_array, int row_dim_in, int col_dim, LDBLE fill_facto
{
int i, j;
int row_dim = row_dim_in + 1;
if (tally_table == NULL)
//if (tally_table == NULL)
if (tally_table.size() == 0)
{
input_error++;
error_msg("Tally table not defined, get_tally_table_rows_columns",
@ -245,7 +246,7 @@ get_tally_table_rows_columns(int *rows, int *columns)
{
*rows = 0;
*columns = 0;
if (tally_table == NULL)
if (tally_table.size() == 0)
{
input_error++;
error_msg("tally table not defined, get_tally_table_rows_columns",
@ -266,7 +267,7 @@ get_tally_table_row_heading(int row, char *string)
* row is C row number
*/
strcpy(string, "");
if (tally_table == NULL)
if (tally_table.size() == 0)
{
input_error++;
error_msg("Tally table not defined, get_tally_table row_heading",
@ -295,7 +296,7 @@ get_tally_table_column_heading(int column, int *type, char *string)
*/
*type = -1;
strcpy(string, "");
if (tally_table == NULL)
if (tally_table.size() == 0)
{
input_error++;
error_msg("tally table not defined, get_tally_table_column_heading",
@ -321,7 +322,7 @@ free_tally_table(void)
/* ---------------------------------------------------------------------- */
{
int i, k;
if (tally_table == NULL)
if (tally_table.size() == 0)
return (OK);
for (i = 0; i < count_tally_table_columns; i++)
{
@ -333,7 +334,7 @@ free_tally_table(void)
tally_table[i].total[k]);
}
}
tally_table = (class tally *) free_check_null(tally_table);
//tally_table = (class tally *) free_check_null(tally_table);
t_buffer = (class tally_buffer *) free_check_null(t_buffer);
return (OK);
}
@ -1214,10 +1215,11 @@ extend_tally_table(void)
* adds another column to tally_table
* increments number of columns
*/
tally_table = (class tally *) PHRQ_realloc((void *) tally_table,
(count_tally_table_columns + 1) * sizeof(class tally));
if (tally_table == NULL)
malloc_error();
//tally_table = (class tally *) PHRQ_realloc((void *) tally_table,
// (count_tally_table_columns + 1) * sizeof(class tally));
//if (tally_table == NULL)
// malloc_error();
tally_table.resize(count_tally_table_columns + 1);
for (i = 0; i < 3; i++)
{
tally_table[count_tally_table_columns].total[i] = (class tally_buffer *)