diff --git a/src/grib_context.cc b/src/grib_context.cc index 75681a195..b8d71ae0e 100644 --- a/src/grib_context.cc +++ b/src/grib_context.cc @@ -810,14 +810,14 @@ void grib_context_reset(grib_context* c) if (c->grib_definition_files_dir) { grib_string_list* next = c->grib_definition_files_dir; - grib_string_list* cur = NULL; + grib_string_list* cur = NULL; while (next) { cur = next; next = next->next; grib_context_free(c, cur->value); grib_context_free(c, cur); } - c->grib_definition_files_dir=0; + c->grib_definition_files_dir = 0; } if (c->multi_support_on) diff --git a/src/grib_fieldset.cc b/src/grib_fieldset.cc index a37013844..3bee07caf 100644 --- a/src/grib_fieldset.cc +++ b/src/grib_fieldset.cc @@ -113,14 +113,12 @@ static int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int t static void grib_fieldset_delete_columns(grib_fieldset* set) { - int i = 0; - grib_context* c; - if (!set) return; - c = set->context; - for (i = 0; i < set->columns_size; i++) { + const grib_context* c = set->context; + + for (size_t i = 0; i < set->columns_size; i++) { int j = 0; switch (set->columns[i].type) { case GRIB_TYPE_LONG: @@ -146,22 +144,19 @@ static void grib_fieldset_delete_columns(grib_fieldset* set) static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) { - double* newdoubles; - long* newlongs; - char** newstrings; - int* newerrors; - int i = 0; - grib_context* c; - if (!set || !set->columns) return GRIB_INVALID_ARGUMENT; - c = set->context; + double* newdoubles = NULL; + long* newlongs = NULL; + char** newstrings = NULL; + int* newerrors = NULL; + const grib_context* c = set->context; if (newsize <= set->columns[0].values_array_size) return 0; - for (i = 0; i < set->columns_size; i++) { + for (size_t i = 0; i < set->columns_size; i++) { switch (set->columns[i].type) { case GRIB_TYPE_LONG: newlongs = (long*)grib_context_realloc(c, set->columns[i].long_values, @@ -818,12 +813,9 @@ static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize) static void grib_fieldset_delete_int_array(grib_int_array* f) { - grib_context* c = NULL; - - if (!f) - return; - c = f->context; + if (!f) return; + const grib_context* c = f->context; grib_context_free(c, f->el); grib_context_free(c, f); } diff --git a/src/grib_filepool.cc b/src/grib_filepool.cc index 21f0a5b22..f651c590d 100644 --- a/src/grib_filepool.cc +++ b/src/grib_filepool.cc @@ -287,8 +287,8 @@ void grib_file_pool_delete_file(grib_file* file) void grib_file_close(const char* filename, int force, int* err) { - grib_file* file = NULL; - grib_context* context = grib_context_get_default(); + grib_file* file = NULL; + const grib_context* context = grib_context_get_default(); /* Performance: keep the files open to avoid opening and closing files when writing the output. */ /* So only call fclose() when too many files are open. */