Commit 7e0bb76c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Magplot: removed include of dmemory.h

parent 8a0fe23e
Pipeline #4858 passed with stages
in 21 minutes and 1 second
......@@ -34,7 +34,6 @@
#include "util_string.h"
#include "cdo_vlist.h"
#include "functs.h"
#include "dmemory.h"
#include "printinfo.h"
#define DBG 0
......@@ -298,7 +297,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
fprintf(stderr, "STAT %d\n", (int) stat);
}
char ***date_time_str = (char ***) Malloc(nfiles * sizeof(char **));
char ***date_time_str = (char ***) malloc(nfiles * sizeof(char **));
std::vector<double> date_time;
std::vector<double> mean_val, std_dev_val;
......@@ -307,7 +306,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
if (stat)
{
/* if all files are of same number of steps, only one date_time_str array is being used */
date_time_str[0] = (char **) Malloc(ntime_steps * sizeof(char *));
date_time_str[0] = (char **) malloc(ntime_steps * sizeof(char *));
date_time.resize(ntime_steps);
mean_val.resize(ntime_steps);
......@@ -318,7 +317,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
for (tsID = 0; tsID < ntime_steps; ++tsID)
{
date_time[tsID] = tsID + 1;
date_time_str[0][tsID] = (char *) Malloc(256);
date_time_str[0][tsID] = (char *) malloc(256);
sprintf(date_time_str[0][tsID], "%s %s", dateToString(vdates[0][tsID]).c_str(), timeToString(vtimes[0][tsID]).c_str());
mean_val[tsID] = 0.;
std_dev_val[tsID] = 0.;
......@@ -399,13 +398,13 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
{
if (DBG) fprintf(stderr, "FILE %ld\n", fileID);
date_time.resize(nts[fileID]);
date_time_str[fileID] = (char **) Malloc(nts[fileID] * sizeof(char *));
date_time_str[fileID] = (char **) malloc(nts[fileID] * sizeof(char *));
for (tsID = 0; tsID < nts[fileID]; ++tsID)
{
date_time[tsID] = tsID + 1;
date_time_str[fileID][tsID] = (char *) Malloc(256);
date_time_str[fileID][tsID] = (char *) malloc(256);
sprintf(date_time_str[fileID][tsID], "%s %s", dateToString(vdates[fileID][tsID]).c_str(),
timeToString(vtimes[fileID][tsID]).c_str());
if (DBG)
......@@ -661,7 +660,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
}
char *lines[1];
lines[0] = (char *) Malloc(1024);
lines[0] = (char *) malloc(1024);
/* To be obtained from Meta Data */
/* sprintf( lines[0],"%s","ExpID : " );*/
/* sprintf( lines[0],"%sxxxx Variable : %s[%s]",lines[0], varname, varunits );*/
......@@ -682,11 +681,11 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
mag_setc("text_justification", "left");
mag_text();
Free(date_time_str);
free(date_time_str);
if (DBG) fprintf(stderr, "%s\n", lines[0]);
Free(lines[0]);
free(lines[0]);
}
static void
......@@ -811,7 +810,7 @@ VerifyGraphParameters(int num_param, std::vector<std::string> &param_names)
halt_flag = true;
fprintf(stderr, "Invalid parameter specification '%s'!\n", param_names[i].c_str());
}
Free(split_str);
free(split_str);
}
if (halt_flag) exit(0);
......
......@@ -31,7 +31,6 @@
#include "results_template_parser.h"
#include "string_utilities.h"
#include "util_string.h"
#include "dmemory.h"
#include "printinfo.h"
#define DBG 0
......@@ -173,7 +172,8 @@ int checkprojection(char *projection_in);
/* Magics default values */
int COUNT = 10, isRGB = false, THICKNESS = 1, NUM_LEVELS = 0, FILE_SPLIT = false;
double YMIN = 1.0e+200, YMAX = -1.0e+200, INTERVAL = 8.0, RESOLUTION = 10.0f, *LEV_LIST = nullptr;
double YMIN = 1.0e+200, YMAX = -1.0e+200, INTERVAL = 8.0, RESOLUTION = 10.0f;
double *LEV_LIST = nullptr;
double LAT_MIN = 1.0e+200, LAT_MAX = -1.e+200;
double LON_MIN = 1.0e+200, LON_MAX = -1.e+200;
const char *COLOUR = nullptr, *COLOUR_MIN = nullptr, *COLOUR_MAX = nullptr, *STYLE = nullptr, *DEVICE = nullptr,
......@@ -189,7 +189,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
double dlon = 0, dlat = 0;
char plotfilename[4096];
char *titlename;
int j, split_str_count;
int j;
const char *sep_char = "=";
char **split_str = nullptr;
char tempname[256];
......@@ -203,9 +203,8 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
for (i = 0; i < nparam; ++i)
{
split_str_count = 0;
sep_char = "=";
split_str_count = cstrSplitWithSeperator(params[i].c_str(), sep_char, &split_str);
const auto split_str_count = cstrSplitWithSeperator(params[i].c_str(), sep_char, &split_str);
if (cdo_cmpstr(split_str[0], "min")) fprintf(stderr, "Min Val %g\n", YMIN);
if (cdo_cmpstr(split_str[0], "max")) fprintf(stderr, "Max Val %g\n", YMAX);
......@@ -231,7 +230,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
if (cdo_cmpstr(split_str[0], "lon_max")) fprintf(stderr, "Lon Max Val %g\n", LON_MAX);
if (cdo_cmpstr(split_str[0], "projection")) fprintf(stderr, "PROJECTION %s\n", PROJECTION);
Free(split_str);
free(split_str);
}
}
......@@ -532,7 +531,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
mag_setc("text_justification", "left");
mag_text();
if (LEV_LIST) Free(LEV_LIST);
if (LEV_LIST) free(LEV_LIST);
}
static void
......@@ -560,7 +559,6 @@ verifyPlotParameters(int num_param, const std::vector<std::string> &param_names,
{
int i, j, k;
bool found = false, syntax = true, halt_flag = false;
int split_str_count;
int param_count = 0;
const char **params = nullptr;
char **split_str = nullptr, **split_str1 = nullptr;
......@@ -577,10 +575,9 @@ verifyPlotParameters(int num_param, const std::vector<std::string> &param_names,
for (i = 0; i < num_param; ++i)
{
split_str_count = 0;
found = false;
syntax = true;
split_str_count = cstrSplitWithSeperator(param_names[i].c_str(), sep_char, &split_str);
auto split_str_count = cstrSplitWithSeperator(param_names[i].c_str(), sep_char, &split_str);
if (DBG) fprintf(stderr, "Verifying params!\n");
......@@ -769,12 +766,9 @@ verifyPlotParameters(int num_param, const std::vector<std::string> &param_names,
if (syntax == true)
{
NUM_LEVELS = split_str_count;
LEV_LIST = (double *) Malloc(sizeof(double) * split_str_count);
for (k = 0; k < split_str_count; k++)
{
LEV_LIST[k] = atof(split_str1[k]);
}
Free(split_str1);
LEV_LIST = (double *) malloc(split_str_count * sizeof(double));
for (k = 0; k < split_str_count; k++) LEV_LIST[k] = atof(split_str1[k]);
free(split_str1);
}
}
}
......@@ -798,7 +792,7 @@ verifyPlotParameters(int num_param, const std::vector<std::string> &param_names,
fprintf(stderr, "Invalid parameter specification '%s'\n", param_names[i].c_str());
}
if (split_str) Free(split_str);
if (split_str) free(split_str);
} /*** Loop over params ****/
if (halt_flag) exit(0);
......@@ -807,8 +801,7 @@ verifyPlotParameters(int num_param, const std::vector<std::string> &param_names,
int
checkcolour(char *colour_in)
{
int i, n;
int split_str_count;
int i;
const char *sep_char = ",";
char **split_str = nullptr;
float rgb_values[3];
......@@ -821,11 +814,11 @@ checkcolour(char *colour_in)
if (strchr(colour_in, ';') == nullptr || strstr(colour_in, "RGB(") == nullptr)
{
cdoWarning("Found 'RGB=true',Specify Colour in 'RGB(r;g;b)' ( where r,g,b in [0.0,1.0] ) format!");
Free(split_str);
free(split_str);
return 1;
}
n = strlen(colour_in);
int n = strlen(colour_in);
if (DBG) fprintf(stdout, " count %d original colour %s RGB %d\n", n, colour_in, isRGB);
......@@ -843,12 +836,12 @@ checkcolour(char *colour_in)
if (DBG) fprintf(stdout, " count %d modified color %s \n", (int) strlen(temp), temp);
sep_char = ";";
split_str_count = cstrSplitWithSeperator(temp, sep_char, &split_str);
const auto split_str_count = cstrSplitWithSeperator(temp, sep_char, &split_str);
if (split_str_count != 3)
{
cdoWarning(" Colour specified in Improper format!");
Free(split_str);
free(split_str);
return 1;
}
......@@ -859,18 +852,18 @@ checkcolour(char *colour_in)
if (rgb_values[0] + rgb_values[1] + rgb_values[2] > 3.0f || rgb_values[0] + rgb_values[1] + rgb_values[2] < 0.0f)
{
cdoWarning(" RGB Colour specified with Improper values!");
Free(split_str);
free(split_str);
return 1;
}
Free(split_str);
free(split_str);
}
else
{
if (strchr(colour_in, ';') != nullptr || strstr(colour_in, "RGB(") != nullptr)
{
cdoWarning("Found Colour with 'RGB(r;g;b)' format, set parameter RGB='true' !");
Free(split_str);
free(split_str);
return 1;
}
......@@ -913,12 +906,12 @@ ReadColourTable(char *filepath)
}
USR_COLOUR_COUNT = 0;
USR_COLOUR_TABLE = (char **) Malloc(num_colors * sizeof(char *));
char **temp_table = (char **) Malloc(num_colors * sizeof(char *));
USR_COLOUR_TABLE = (char **) malloc(num_colors * sizeof(char *));
char **temp_table = (char **) malloc(num_colors * sizeof(char *));
for (i = 0; i < num_colors; i++)
{
temp_table[i] = (char *) Malloc(256 * sizeof(char));
temp_table[i] = (char *) malloc(256 * sizeof(char));
fscanf(fp, "%s", temp_table[i]);
if (DBG) fprintf(stdout, "%s\n", temp_table[i]);
}
......@@ -944,13 +937,10 @@ ReadColourTable(char *filepath)
}
}
if (USR_COLOUR_COUNT < num_colors)
{
cdoWarning(" Discarding improper format colours and continuing!");
}
if (USR_COLOUR_COUNT < num_colors) cdoWarning(" Discarding improper format colours and continuing!");
for (i = 0; i < num_colors; i++) Free(temp_table[i]);
Free(temp_table);
for (i = 0; i < num_colors; i++) free(temp_table[i]);
free(temp_table);
return 0;
}
......
......@@ -20,7 +20,6 @@
#include "cdo_output.h"
#include "compare.h"
#include "dmemory.h"
#include "magics_template_parser.h"
#include "string_utilities.h"
......@@ -139,7 +138,6 @@ SetMagicsParameterValue(const char *, const char *, const char *)
char **split_str = nullptr;
const char *sep_char = ",";
const char *search_char = ";";
double *float_param_list = nullptr;
if (param_name == nullptr)
{
......@@ -199,17 +197,16 @@ SetMagicsParameterValue(const char *, const char *, const char *)
split_str_count = cstrSplitWithSeperator(param_value, sep_char, &split_str);
if (split_str_count)
{
float_param_list = (double *) Malloc(sizeof(double) * split_str_count);
std::vector<double> float_param_list(split_str_count);
for (i = 0; i < split_str_count; i++)
{
#if 0
fprintf(stderr, "%d %d %s\n", i, split_str_count, split_str[i]);
fprintf(stderr, "%d %d %s\n", i, split_str_count, split_str[i]);
#endif
float_param_list[i] = atof(split_str[i]);
}
mag_set1r(param_name, float_param_list, split_str_count);
Free(float_param_list);
Free(split_str);
mag_set1r(param_name, float_param_list.data(), split_str_count);
free(split_str);
}
}
......@@ -226,14 +223,13 @@ SetMagicsParameterValue(const char *, const char *, const char *)
split_str_count = cstrSplitWithSeperator(param_value, sep_char, &split_str);
if (split_str_count)
{
int *int_param_list = (int *) Malloc(sizeof(int) * split_str_count);
std::vector<int> int_param_list(split_str_count);
for (i = 0; i < split_str_count; i++)
{
int_param_list[i] = atoi(split_str[i]);
}
mag_set1i(param_name, int_param_list, split_str_count);
Free(int_param_list);
Free(split_str);
mag_set1i(param_name, int_param_list.data(), split_str_count);
free(split_str);
}
}
......@@ -258,7 +254,7 @@ SetMagicsParameterValue(const char *, const char *, const char *)
if (DBG) fprintf(stderr, "Input strarr is %s split str count is %d Sep char is %s\n", param_value, split_str_count, sep_char);
mag_set1c(param_name, (const char **) split_str, split_str_count);
Free(split_str);
free(split_str);
}
else
{
......
......@@ -17,7 +17,6 @@
#include <algorithm>
#include "cdo_output.h"
#include "dmemory.h"
#include "string_utilities.h"
#include "util_string.h"
......@@ -34,6 +33,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, std::ve
}
return split_string.size();
}
int
cstrSplitWithSeperator(const char *source_string, const char *seperator, char ***ptr_split_string)
{
......@@ -54,7 +54,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char **
if (duplicate_src[i] == *seperator) sep_count++;
}
temp_list = (char **) Malloc(sizeof(char *) * (sep_count + 1));
temp_list = (char **) malloc(sizeof(char *) * (sep_count + 1));
if (DBG) fprintf(stderr, "Input str %s , seperator %s sep count %d\n", duplicate_src, seperator, sep_count);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment