mirror of https://github.com/ecmwf/eccodes.git
ECC-1419: C API: codes_fieldset_new_from_files: The 'filenames' argument should be const
This commit is contained in:
parent
f582b8d418
commit
f29e6ca366
|
@ -48,15 +48,15 @@ int main(int argc, char** argv)
|
|||
double lat = -40, lon = 15;
|
||||
int mode = 0;
|
||||
int count;
|
||||
char** filenames;
|
||||
const char** filenames = NULL;
|
||||
codes_nearest* nearest = NULL;
|
||||
|
||||
if (argc < 2) usage(argv[0]);
|
||||
|
||||
nfiles = argc - 1;
|
||||
filenames = (char**)malloc(sizeof(char*) * nfiles);
|
||||
filenames = (const char**)malloc(sizeof(char*) * nfiles);
|
||||
for (i = 0; i < nfiles; i++)
|
||||
filenames[i] = (char*)strdup(argv[i + 1]);
|
||||
filenames[i] = strdup(argv[i + 1]);
|
||||
|
||||
set = codes_fieldset_new_from_files(0, filenames, nfiles, 0, 0, 0, order_by, &err);
|
||||
CODES_CHECK(err, 0);
|
||||
|
@ -91,7 +91,7 @@ int main(int argc, char** argv)
|
|||
if (set) codes_fieldset_delete(set);
|
||||
|
||||
for (i = 0; i < nfiles; i++)
|
||||
free(filenames[i]);
|
||||
free((char*)filenames[i]);
|
||||
free(filenames);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -69,7 +69,7 @@ void codes_check(const char* call, const char* file, int line, int e, const char
|
|||
|
||||
/* Fieldsets */
|
||||
/******************************************************************************/
|
||||
grib_fieldset* codes_fieldset_new_from_files(grib_context* c, char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err)
|
||||
grib_fieldset* codes_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err)
|
||||
{
|
||||
return grib_fieldset_new_from_files(c, filenames, nfiles, keys, nkeys, where_string, order_by_string, err);
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ typedef struct grib_util_packing_spec codes_util_packing_spec;
|
|||
typedef struct grib_util_grid_spec codes_util_grid_spec;
|
||||
|
||||
|
||||
codes_fieldset* codes_fieldset_new_from_files(codes_context* c, char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
codes_fieldset* codes_fieldset_new_from_files(codes_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
|
||||
void codes_fieldset_delete(codes_fieldset* set);
|
||||
void codes_fieldset_rewind(codes_fieldset* set);
|
||||
|
|
|
@ -986,7 +986,7 @@ long grib_date_to_julian(long ddate);
|
|||
|
||||
/* grib_fieldset.c */
|
||||
int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int type);
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
int grib_fieldset_apply_where(grib_fieldset* set, const char* where_string);
|
||||
int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string);
|
||||
void grib_fieldset_delete_order_by(grib_context* c, grib_order_by* order_by);
|
||||
|
|
|
@ -235,7 +235,7 @@ typedef struct bufr_descriptor bufr_descriptor;
|
|||
typedef struct bufr_descriptors_array bufr_descriptors_array;
|
||||
typedef struct bufr_descriptors_map_list bufr_descriptors_map_list;
|
||||
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, const char* filenames[], int nfiles, const char** keys, int nkeys, const char* where_string, const char* order_by_string, int* err);
|
||||
void grib_fieldset_delete(grib_fieldset* set);
|
||||
void grib_fieldset_rewind(grib_fieldset* set);
|
||||
int grib_fieldset_apply_order_by(grib_fieldset* set, const char* order_by_string);
|
||||
|
|
|
@ -254,7 +254,7 @@ static int grib_fieldset_column_copy_from_handle(grib_handle* h, grib_fieldset*
|
|||
}
|
||||
|
||||
/* --------------- grib_fieldset functions ------------------*/
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, char* filenames[],
|
||||
grib_fieldset* grib_fieldset_new_from_files(grib_context* c, const char* filenames[],
|
||||
int nfiles, const char** keys, int nkeys,
|
||||
const char* where_string, const char* order_by_string, int* err)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ int main(int argc, char** argv)
|
|||
{
|
||||
int err = 0;
|
||||
long step;
|
||||
char** filenames;
|
||||
const char** filenames = NULL;
|
||||
size_t nkeys, nfiles, i=0;
|
||||
const char* keys[] = { "step:i", "date", "paramId", "levelType" };
|
||||
grib_fieldset* set = NULL;
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char** argv)
|
|||
order_by = argv[1];
|
||||
|
||||
nfiles = argc - 2;
|
||||
filenames = (char**)malloc(sizeof(char*) * nfiles);
|
||||
filenames = (const char**)malloc(sizeof(char*) * nfiles);
|
||||
for (i = 0; i < nfiles; i++)
|
||||
filenames[i] = (char*)strdup(argv[i + 2]);
|
||||
|
||||
|
@ -73,7 +73,7 @@ int main(int argc, char** argv)
|
|||
grib_fieldset_delete(set);
|
||||
grib_handle_delete(h);
|
||||
for (i = 0; i < nfiles; i++)
|
||||
free(filenames[i]);
|
||||
free((char*)filenames[i]);
|
||||
free(filenames);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -50,12 +50,12 @@ int main(int argc, char** argv)
|
|||
double lat = -40, lon = 15;
|
||||
int mode = 0;
|
||||
int count;
|
||||
char** filenames;
|
||||
const char** filenames = NULL;
|
||||
codes_nearest* nearest = NULL;
|
||||
|
||||
if (argc < 2) usage(argv[0]);
|
||||
|
||||
filenames = (char**)malloc(sizeof(char*) * max_numfiles);
|
||||
filenames = (const char**)malloc(sizeof(char*) * max_numfiles);
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-n") == 0) {
|
||||
|
@ -64,7 +64,7 @@ int main(int argc, char** argv)
|
|||
else {
|
||||
if (j >= max_numfiles)
|
||||
break;
|
||||
filenames[j++] = (char*)strdup(argv[i]);
|
||||
filenames[j++] = strdup(argv[i]);
|
||||
}
|
||||
}
|
||||
nfiles = j;
|
||||
|
@ -114,7 +114,7 @@ int main(int argc, char** argv)
|
|||
if (set) codes_fieldset_delete(set);
|
||||
|
||||
for (i = 0; i < nfiles; ++i) {
|
||||
free(filenames[i]);
|
||||
free((char*)filenames[i]);
|
||||
}
|
||||
free(filenames);
|
||||
|
||||
|
|
Loading…
Reference in New Issue