Const correctness

This commit is contained in:
Shahram Najm 2017-01-13 17:24:36 +00:00
parent 953c6ed1d5
commit 9495fccfec
10 changed files with 19 additions and 19 deletions

View File

@ -65,7 +65,7 @@ void codes_check(const char* call,const char* file,int line,int e,const char* m
/* Fieldsets */ /* Fieldsets */
/******************************************************************************/ /******************************************************************************/
grib_fieldset *codes_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err) grib_fieldset *codes_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, 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); return grib_fieldset_new_from_files(c, filenames, nfiles, keys, nkeys, where_string, order_by_string, err);
} }

View File

@ -179,7 +179,7 @@ typedef struct grib_util_packing_spec codes_util_packing_spec;
typedef struct grib_util_grid_spec codes_util_grid_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, char **keys, int nkeys, char *where_string, char *order_by_string, int *err); codes_fieldset *codes_fieldset_new_from_files(codes_context *c, char *filenames[], int nfiles, 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_delete(codes_fieldset* set);
void codes_fieldset_rewind(codes_fieldset* set); void codes_fieldset_rewind(codes_fieldset* set);

View File

@ -225,7 +225,7 @@ typedef struct grib_viarray grib_viarray;
typedef struct bufr_descriptor bufr_descriptor; typedef struct bufr_descriptor bufr_descriptor;
typedef struct bufr_descriptors_array bufr_descriptors_array; typedef struct bufr_descriptors_array bufr_descriptors_array;
grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err); grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, 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_delete(grib_fieldset* set);
void grib_fieldset_rewind(grib_fieldset* set); void grib_fieldset_rewind(grib_fieldset* set);
int grib_fieldset_apply_order_by(grib_fieldset* set,const char* order_by_string); int grib_fieldset_apply_order_by(grib_fieldset* set,const char* order_by_string);
@ -801,7 +801,7 @@ int grib_get_double_elements(grib_handle* h, const char* key, int* i, long size,
* @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output * @param length : the address of a size_t that contains allocated length of the string on input, and that contains the actual length of the string on output
* @return 0 if OK, integer value on error * @return 0 if OK, integer value on error
*/ */
int grib_get_string (grib_handle* h, const char* key, char* mesg, size_t *length); int grib_get_string(grib_handle* h, const char* key, char* mesg, size_t *length);
int grib_get_string_array(grib_handle* h, const char* name, char** val, size_t *length); int grib_get_string_array(grib_handle* h, const char* name, char** val, size_t *length);

View File

@ -990,7 +990,7 @@ long grib_date_to_julian(long ddate);
/* grib_fieldset.c */ /* grib_fieldset.c */
int grib_fieldset_new_column(grib_fieldset *set, int id, char *key, int type); int grib_fieldset_new_column(grib_fieldset *set, int id, char *key, int type);
int grib_fieldset_column_copy_from_handle(grib_handle *h, grib_fieldset *set, int i); int grib_fieldset_column_copy_from_handle(grib_handle *h, grib_fieldset *set, int i);
grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, char **keys, int nkeys, char *where_string, char *order_by_string, int *err); grib_fieldset *grib_fieldset_new_from_files(grib_context *c, char *filenames[], int nfiles, 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_where(grib_fieldset *set, const char *where_string);
int grib_fieldset_apply_order_by(grib_fieldset *set, const char *order_by_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); void grib_fieldset_delete_order_by(grib_context *c, grib_order_by *order_by);

View File

@ -33,7 +33,7 @@ static grib_fieldset* grib_fieldset_create_from_order_by(grib_context* c,grib_or
int* err); int* err);
static int grib_fieldset_resize(grib_fieldset* set,size_t newsize); static int grib_fieldset_resize(grib_fieldset* set,size_t newsize);
static void grib_trim(char** x); static void grib_trim(char** x);
static grib_order_by* grib_fieldset_new_order_by(grib_context* c,char* z); static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* z);
static int grib_fieldset_compare(grib_fieldset* set,int* i,int* j); static int grib_fieldset_compare(grib_fieldset* set,int* i,int* j);
static void grib_fieldset_sort(grib_fieldset* set, int beg, int theEnd); static void grib_fieldset_sort(grib_fieldset* set, int beg, int theEnd);
static int grib_fieldset_columns_resize(grib_fieldset* set,size_t newsize); static int grib_fieldset_columns_resize(grib_fieldset* set,size_t newsize);
@ -238,8 +238,8 @@ int grib_fieldset_column_copy_from_handle(grib_handle* h,grib_fieldset* set,int
/* --------------- grib_fieldset functions ------------------*/ /* --------------- 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,char* filenames[],
int nfiles, char** keys,int nkeys, int nfiles, char** keys, int nkeys,
char* where_string,char* order_by_string,int* err) const char* where_string, const char* order_by_string, int* err)
{ {
int i=0; int i=0;
int ret=GRIB_SUCCESS; int ret=GRIB_SUCCESS;
@ -403,7 +403,7 @@ int grib_fieldset_apply_order_by(grib_fieldset* set,const char* order_by_string)
set->order_by=0; set->order_by=0;
} }
ob=grib_fieldset_new_order_by(set->context,(char*)order_by_string); ob=grib_fieldset_new_order_by(set->context, order_by_string);
if ((err=grib_fieldset_set_order_by(set,ob)) != GRIB_SUCCESS) if ((err=grib_fieldset_set_order_by(set,ob)) != GRIB_SUCCESS)
return err; return err;
@ -509,7 +509,7 @@ void grib_fieldset_delete_order_by(grib_context* c,grib_order_by* order_by)
return; return;
} }
static grib_order_by* grib_fieldset_new_order_by(grib_context* c,char* obstr) static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* obstr)
{ {
char *t1=0,*t2=0,*p=0; char *t1=0,*t2=0,*p=0;
int id=0; int id=0;

View File

@ -155,7 +155,7 @@ int grib_copy_namespace(grib_handle* dest, const char* name, grib_handle* src)
if (!dest || !src) return GRIB_NULL_HANDLE; if (!dest || !src) return GRIB_NULL_HANDLE;
iter=grib_keys_iterator_new(src,0,(char*)name); iter=grib_keys_iterator_new(src,0,name);
if (!iter) { if (!iter) {
grib_context_log(src->context,GRIB_LOG_ERROR,"grib_copy_namespace: unable to get iterator for %s",name ); grib_context_log(src->context,GRIB_LOG_ERROR,"grib_copy_namespace: unable to get iterator for %s",name );
@ -1383,7 +1383,7 @@ static int grib_get_key_value(grib_handle* h,grib_key_value_list* kv)
kv->error=err; kv->error=err;
break; break;
case GRIB_NAMESPACE: case GRIB_NAMESPACE:
iter=grib_keys_iterator_new(h,0,(char*)kv->name); iter=grib_keys_iterator_new(h,0,kv->name);
list=(grib_key_value_list*)grib_context_malloc_clear(h->context,sizeof(grib_key_value_list)); list=(grib_key_value_list*)grib_context_malloc_clear(h->context,sizeof(grib_key_value_list));
kv->namespace_value=list; kv->namespace_value=list;
while(grib_keys_iterator_next(iter)) while(grib_keys_iterator_next(iter))

View File

@ -1181,7 +1181,7 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted((char*)options->compare[i].name)) continue; if (blacklisted((char*)options->compare[i].name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(handle1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(handle1,0,options->compare[i].name);
if (!iter) { if (!iter) {
grib_context_log(handle1->context, GRIB_LOG_ERROR, "unable to get iterator"); grib_context_log(handle1->context, GRIB_LOG_ERROR, "unable to get iterator");
exit(1); exit(1);
@ -1241,7 +1241,7 @@ static int compare_handles(grib_handle* handle1, grib_handle* handle2, grib_runt
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted(name)) continue; if (blacklisted(name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(handle1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(handle1,0,options->compare[i].name);
if (!iter) { if (!iter) {
grib_context_log(handle1->context, GRIB_LOG_ERROR, grib_context_log(handle1->context, GRIB_LOG_ERROR,
"ERROR: unable to get keys iterator for %s",options->compare[i].name); "ERROR: unable to get keys iterator for %s",options->compare[i].name);

View File

@ -673,7 +673,7 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
} }
if (ns) { if (ns) {
kiter=grib_keys_iterator_new(h,0,(char*)ns); kiter=grib_keys_iterator_new(h,0,ns);
if (!kiter) { if (!kiter) {
fprintf(dump_file,"ERROR: Unable to create keys iterator\n"); fprintf(dump_file,"ERROR: Unable to create keys iterator\n");
exit(1); exit(1);

View File

@ -841,7 +841,7 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted((char*)options->compare[i].name)) continue; if (blacklisted((char*)options->compare[i].name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(h1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(h1,0,options->compare[i].name);
if (!iter) { if (!iter) {
printf("ERROR: unable to get iterator\n"); printf("ERROR: unable to get iterator\n");
exit(1); exit(1);
@ -901,7 +901,7 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted(name)) continue; if (blacklisted(name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(h1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(h1,0,options->compare[i].name);
if (!iter) { if (!iter) {
printf("ERROR: unable to get iterator for %s\n",options->compare[i].name ); printf("ERROR: unable to get iterator for %s\n",options->compare[i].name );
exit(1); exit(1);

View File

@ -1067,7 +1067,7 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted((char*)options->compare[i].name)) continue; if (blacklisted((char*)options->compare[i].name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(h1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(h1,0,options->compare[i].name);
if (!iter) { if (!iter) {
printf("ERROR: unable to get iterator\n"); printf("ERROR: unable to get iterator\n");
exit(1); exit(1);
@ -1127,7 +1127,7 @@ static int compare_handles(grib_handle* h1,grib_handle* h2,grib_runtime_options*
for (i=0; i< options->compare_count; i++) { for (i=0; i< options->compare_count; i++) {
if (blacklisted(name)) continue; if (blacklisted(name)) continue;
if (options->compare[i].type == GRIB_NAMESPACE) { if (options->compare[i].type == GRIB_NAMESPACE) {
iter=grib_keys_iterator_new(h1,0,(char*)options->compare[i].name); iter=grib_keys_iterator_new(h1,0,options->compare[i].name);
if (!iter) { if (!iter) {
printf("ERROR: unable to get iterator for %s\n",options->compare[i].name ); printf("ERROR: unable to get iterator for %s\n",options->compare[i].name );
exit(1); exit(1);