From c71df54c8f1ca4ae44df450d656df5f3c5be0d27 Mon Sep 17 00:00:00 2001 From: shahramn Date: Sat, 12 Oct 2024 17:06:11 +0100 Subject: [PATCH] Dead code removal --- .../grib_accessor_class_expanded_descriptors.cc | 14 +++++++------- src/eccodes_prototypes.h | 4 ++-- src/grib_bufr_descriptors_array.cc | 11 +++++------ src/grib_hash_array.cc | 3 ++- src/grib_iarray.cc | 1 - src/grib_yacc.cc | 4 ++-- src/griby.y | 4 ++-- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/accessor/grib_accessor_class_expanded_descriptors.cc b/src/accessor/grib_accessor_class_expanded_descriptors.cc index f32119a91..6acb4e878 100644 --- a/src/accessor/grib_accessor_class_expanded_descriptors.cc +++ b/src/accessor/grib_accessor_class_expanded_descriptors.cc @@ -141,7 +141,7 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex if (*err) goto cleanup; - inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); + inner_unexpanded = grib_bufr_descriptors_array_new(DESC_SIZE_INIT, DESC_SIZE_INCR); for (i = 0; i < size; i++) { vv = grib_bufr_descriptor_new(tablesAccessor_, v_array[i], !SILENT, err); inner_unexpanded = grib_bufr_descriptors_array_push(inner_unexpanded, vv); @@ -178,7 +178,7 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex grib_bufr_descriptors_array_push(expanded, u); idx = expanded->n - 1; size = 0; - inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); + inner_unexpanded = grib_bufr_descriptors_array_new(DESC_SIZE_INIT, DESC_SIZE_INCR); /* Number of descriptors to replicate cannot be more than what's left */ if (us->X + 1 > unexpanded->n) { @@ -241,7 +241,7 @@ void grib_accessor_expanded_descriptors_t::__expand(bufr_descriptors_array* unex printf("+++ pop %06ld [%s]\n", ur[j]->code, descriptor_type_name(ur[j]->type)); #endif } - inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); + inner_unexpanded = grib_bufr_descriptors_array_new(DESC_SIZE_INIT, DESC_SIZE_INCR); for (j = 0; j < us->X; j++) { urc = grib_bufr_descriptor_clone(ur[j]); grib_bufr_descriptors_array_push(inner_unexpanded, urc); @@ -404,13 +404,13 @@ cleanup: bufr_descriptors_array* grib_accessor_expanded_descriptors_t::do_expand(bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err) { bufr_descriptors_array* expanded = NULL; - grib_context* c = context_; + #if MYDEBUG int idepth; global_depth++; #endif - expanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR); + expanded = grib_bufr_descriptors_array_new(DESC_SIZE_INIT, DESC_SIZE_INCR); #if MYDEBUG { @@ -533,8 +533,8 @@ int grib_accessor_expanded_descriptors_t::expand() Assert(tablesAccessor_); } - unexpanded = grib_bufr_descriptors_array_new(c, unexpandedSize, DESC_SIZE_INCR); - unexpanded_copy = grib_bufr_descriptors_array_new(c, unexpandedSize, DESC_SIZE_INCR); + unexpanded = grib_bufr_descriptors_array_new(unexpandedSize, DESC_SIZE_INCR); + unexpanded_copy = grib_bufr_descriptors_array_new(unexpandedSize, DESC_SIZE_INCR); operator206yyy_width = 0; for (i = 0; i < unexpandedSize; i++) { bufr_descriptor *aDescriptor1, *aDescriptor2; diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index e6d34a2e7..55f889dea 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -106,7 +106,7 @@ grib_concept_condition* grib_concept_condition_new(grib_context* c, const char* void grib_concept_condition_delete(grib_context* c, grib_concept_condition* v); /* grib_hash_array.cc */ -grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name, grib_iarray* array); +grib_hash_array_value* grib_integer_hash_array_value_new(const char* name, grib_iarray* array); /* grib_bufr_descriptor.cc */ bufr_descriptor* grib_bufr_descriptor_new(grib_accessor* tables_accessor, int code, int silent, int* err); @@ -117,7 +117,7 @@ int grib_bufr_descriptor_can_be_missing(const bufr_descriptor* v); void grib_bufr_descriptor_delete(bufr_descriptor* v); /* grib_bufr_descriptors_array.cc */ -bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t size, size_t incsize); +bufr_descriptors_array* grib_bufr_descriptors_array_new(size_t size, size_t incsize); bufr_descriptor* grib_bufr_descriptors_array_pop_front(bufr_descriptors_array* a); bufr_descriptors_array* grib_bufr_descriptors_array_push(bufr_descriptors_array* v, bufr_descriptor* val); bufr_descriptors_array* grib_bufr_descriptors_array_append(bufr_descriptors_array* v, bufr_descriptors_array* ar); diff --git a/src/grib_bufr_descriptors_array.cc b/src/grib_bufr_descriptors_array.cc index 637cf14eb..a52e130e1 100644 --- a/src/grib_bufr_descriptors_array.cc +++ b/src/grib_bufr_descriptors_array.cc @@ -13,12 +13,11 @@ #define DYN_ARRAY_SIZE_INIT 200 /* Initial size for grib_bufr_descriptors_array_new */ #define DYN_ARRAY_SIZE_INCR 400 /* Increment size for the above */ -bufr_descriptors_array* grib_bufr_descriptors_array_new(grib_context* c, size_t size, size_t incsize) +bufr_descriptors_array* grib_bufr_descriptors_array_new(size_t size, size_t incsize) { bufr_descriptors_array* v = NULL; - if (!c) - c = grib_context_get_default(); + grib_context* c = grib_context_get_default(); v = (bufr_descriptors_array*)grib_context_malloc(c, sizeof(bufr_descriptors_array)); if (!v) { @@ -100,7 +99,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_push(bufr_descriptors_array* if (!v) { size_t start_size = DYN_ARRAY_SIZE_INIT; size_t start_incsize = DYN_ARRAY_SIZE_INCR; - v = grib_bufr_descriptors_array_new(0, start_size, start_incsize); + v = grib_bufr_descriptors_array_new(start_size, start_incsize); } if (v->n >= v->size - v->number_of_pop_front) @@ -119,7 +118,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_append(bufr_descriptors_arra if (!v) { size_t start_size = DYN_ARRAY_SIZE_INIT; size_t start_incsize = DYN_ARRAY_SIZE_INCR; - v = grib_bufr_descriptors_array_new(0, start_size, start_incsize); + v = grib_bufr_descriptors_array_new(start_size, start_incsize); } for (i = 0; i < ar->n; i++) { @@ -139,7 +138,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_append(bufr_descriptors_arra // if (!v) { // size_t start_size = DYN_ARRAY_SIZE_INIT; // size_t start_incsize = DYN_ARRAY_SIZE_INCR; -// v = grib_bufr_descriptors_array_new(0, start_size, start_incsize); +// v = grib_bufr_descriptors_array_new(start_size, start_incsize); // } // if (v->number_of_pop_front) { // v->v--; diff --git a/src/grib_hash_array.cc b/src/grib_hash_array.cc index ec556c904..42e0146e4 100644 --- a/src/grib_hash_array.cc +++ b/src/grib_hash_array.cc @@ -11,8 +11,9 @@ #include "grib_api_internal.h" -grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name, grib_iarray* array) +grib_hash_array_value* grib_integer_hash_array_value_new(const char* name, grib_iarray* array) { + grib_context* c = grib_context_get_default(); grib_hash_array_value* v = (grib_hash_array_value*)grib_context_malloc_clear_persistent(c, sizeof(grib_hash_array_value)); v->name = grib_context_strdup_persistent(c, name); diff --git a/src/grib_iarray.cc b/src/grib_iarray.cc index f29787b2e..85ad7bca5 100644 --- a/src/grib_iarray.cc +++ b/src/grib_iarray.cc @@ -196,7 +196,6 @@ long* grib_iarray_get_array(grib_iarray* v) { long* vv; size_t i; - DEBUG_ASSERT(c); grib_context* c = grib_context_get_default(); vv = (long*)grib_context_malloc_clear(c, sizeof(long) * v->n); diff --git a/src/grib_yacc.cc b/src/grib_yacc.cc index 81458da8e..c8a774711 100644 --- a/src/grib_yacc.cc +++ b/src/grib_yacc.cc @@ -3545,14 +3545,14 @@ grib_yyreduce: case 214: /* hash_array_value: STRING '=' '[' integer_array ']' */ #line 772 "griby.y" { - (grib_yyval.hash_array_value) = grib_integer_hash_array_value_new(grib_parser_context,(grib_yyvsp[-4].str),(grib_yyvsp[-1].ivalue)); free((grib_yyvsp[-4].str));} + (grib_yyval.hash_array_value) = grib_integer_hash_array_value_new((grib_yyvsp[-4].str),(grib_yyvsp[-1].ivalue)); free((grib_yyvsp[-4].str));} #line 3550 "y.tab.c" break; case 215: /* hash_array_value: IDENT '=' '[' integer_array ']' */ #line 774 "griby.y" { - (grib_yyval.hash_array_value) = grib_integer_hash_array_value_new(grib_parser_context,(grib_yyvsp[-4].str),(grib_yyvsp[-1].ivalue)); free((grib_yyvsp[-4].str));} + (grib_yyval.hash_array_value) = grib_integer_hash_array_value_new((grib_yyvsp[-4].str),(grib_yyvsp[-1].ivalue)); free((grib_yyvsp[-4].str));} #line 3557 "y.tab.c" break; diff --git a/src/griby.y b/src/griby.y index 418216012..823b24c17 100644 --- a/src/griby.y +++ b/src/griby.y @@ -770,9 +770,9 @@ concept_condition: IDENT '=' expression ';' { $$ = grib_concept_condition_new(gr hash_array_value: STRING '=' '[' integer_array ']' { - $$ = grib_integer_hash_array_value_new(grib_parser_context,$1,$4); free($1);} + $$ = grib_integer_hash_array_value_new($1,$4); free($1);} | IDENT '=' '[' integer_array ']' { - $$ = grib_integer_hash_array_value_new(grib_parser_context,$1,$4); free($1);} + $$ = grib_integer_hash_array_value_new($1,$4); free($1);} ; string_or_ident: SUBSTR '(' IDENT ',' INTEGER ',' INTEGER ')' { $$ = new_accessor_expression(grib_parser_context,$3,$5,$7); free($3); }