From 90ed7d1e670baf5e13ef15300a2d0343c8136474 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 5 Jan 2024 17:02:12 +0000 Subject: [PATCH] Dead code removal --- src/eccodes_prototypes.h | 1 - src/grib_value.cc | 152 +++++++++++++++++++-------------------- 2 files changed, 74 insertions(+), 79 deletions(-) diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index 0771c2656..d2d29d60e 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -1201,7 +1201,6 @@ int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, si int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t* length); grib_key_value_list* grib_key_value_list_clone(grib_context* c, grib_key_value_list* list); void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl); -int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list); int grib_get_values(grib_handle* h, grib_values* args, size_t count); int grib_set_values(grib_handle* h, grib_values* args, size_t count); int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest); diff --git a/src/grib_value.cc b/src/grib_value.cc index 50cdca970..513adc2ac 100644 --- a/src/grib_value.cc +++ b/src/grib_value.cc @@ -1598,74 +1598,70 @@ static void grib_clean_key_value(grib_context* c, grib_key_value_list* kv) kv->size = 0; } -static int grib_get_key_value(grib_handle* h, grib_key_value_list* kv) -{ - int err = 0; - size_t size = 0; - grib_keys_iterator* iter = NULL; - grib_key_value_list* list = NULL; - - if (kv->has_value) - grib_clean_key_value(h->context, kv); - - err = grib_get_size(h, kv->name, &size); - if (err) { - kv->error = err; - return err; - } - if (size == 0) - size = 512; - - switch (kv->type) { - case GRIB_TYPE_LONG: - kv->long_value = (long*)grib_context_malloc_clear(h->context, size * sizeof(long)); - err = grib_get_long_array(h, kv->name, kv->long_value, &size); - kv->error = err; - break; - case GRIB_TYPE_DOUBLE: - kv->double_value = (double*)grib_context_malloc_clear(h->context, size * sizeof(double)); - err = grib_get_double_array(h, kv->name, kv->double_value, &size); - kv->error = err; - break; - case GRIB_TYPE_STRING: - grib_get_string_length(h, kv->name, &size); - kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char)); - err = grib_get_string(h, kv->name, kv->string_value, &size); - kv->error = err; - break; - case GRIB_TYPE_BYTES: - kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char)); - err = grib_get_bytes(h, kv->name, (unsigned char*)kv->string_value, &size); - kv->error = err; - break; - case CODES_NAMESPACE: - 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)); - kv->namespace_value = list; - while (grib_keys_iterator_next(iter)) { - list->name = grib_keys_iterator_get_name(iter); - err = grib_get_native_type(h, list->name, &(list->type)); - if (err) - return err; - err = grib_get_key_value(h, list); - if (err) - return err; - list->next = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list)); - list = list->next; - } - grib_keys_iterator_delete(iter); - break; - - default: - err = grib_get_native_type(h, kv->name, &(kv->type)); - if (err) - return err; - err = grib_get_key_value(h, kv); - break; - } - kv->has_value = 1; - return err; -} +// static int grib_get_key_value(grib_handle* h, grib_key_value_list* kv) +// { +// int err = 0; +// size_t size = 0; +// grib_keys_iterator* iter = NULL; +// grib_key_value_list* list = NULL; +// if (kv->has_value) +// grib_clean_key_value(h->context, kv); +// err = grib_get_size(h, kv->name, &size); +// if (err) { +// kv->error = err; +// return err; +// } +// if (size == 0) +// size = 512; +// switch (kv->type) { +// case GRIB_TYPE_LONG: +// kv->long_value = (long*)grib_context_malloc_clear(h->context, size * sizeof(long)); +// err = grib_get_long_array(h, kv->name, kv->long_value, &size); +// kv->error = err; +// break; +// case GRIB_TYPE_DOUBLE: +// kv->double_value = (double*)grib_context_malloc_clear(h->context, size * sizeof(double)); +// err = grib_get_double_array(h, kv->name, kv->double_value, &size); +// kv->error = err; +// break; +// case GRIB_TYPE_STRING: +// grib_get_string_length(h, kv->name, &size); +// kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char)); +// err = grib_get_string(h, kv->name, kv->string_value, &size); +// kv->error = err; +// break; +// case GRIB_TYPE_BYTES: +// kv->string_value = (char*)grib_context_malloc_clear(h->context, size * sizeof(char)); +// err = grib_get_bytes(h, kv->name, (unsigned char*)kv->string_value, &size); +// kv->error = err; +// break; +// case CODES_NAMESPACE: +// 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)); +// kv->namespace_value = list; +// while (grib_keys_iterator_next(iter)) { +// list->name = grib_keys_iterator_get_name(iter); +// err = grib_get_native_type(h, list->name, &(list->type)); +// if (err) +// return err; +// err = grib_get_key_value(h, list); +// if (err) +// return err; +// list->next = (grib_key_value_list*)grib_context_malloc_clear(h->context, sizeof(grib_key_value_list)); +// list = list->next; +// } +// grib_keys_iterator_delete(iter); +// break; +// default: +// err = grib_get_native_type(h, kv->name, &(kv->type)); +// if (err) +// return err; +// err = grib_get_key_value(h, kv); +// break; +// } +// kv->has_value = 1; +// return err; +// } grib_key_value_list* grib_key_value_list_clone(grib_context* c, grib_key_value_list* list) { @@ -1696,16 +1692,16 @@ void grib_key_value_list_delete(grib_context* c, grib_key_value_list* kvl) } } -int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list) -{ - int ret = 0; - grib_key_value_list* kvl = list; - while (kvl) { - ret = grib_get_key_value(h, kvl); - kvl = kvl->next; - } - return ret; -} +// int grib_get_key_value_list(grib_handle* h, grib_key_value_list* list) +// { +// int ret = 0; +// grib_key_value_list* kvl = list; +// while (kvl) { +// ret = grib_get_key_value(h, kvl); +// kvl = kvl->next; +// } +// return ret; +// } int grib_get_values(grib_handle* h, grib_values* args, size_t count) {