From 98cf979823559e656bcdc1bd6bd88e1785c455fb Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 15:59:41 +0100 Subject: [PATCH] ECC-1820: grib_accessors_list.rank made private --- src/accessor/grib_accessors_list.cc | 10 +++++----- src/accessor/grib_accessors_list.h | 5 ++++- src/grib_query.cc | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/accessor/grib_accessors_list.cc b/src/accessor/grib_accessors_list.cc index 3ff166e42..c0114b255 100644 --- a/src/accessor/grib_accessors_list.cc +++ b/src/accessor/grib_accessors_list.cc @@ -46,14 +46,14 @@ void grib_accessors_list::push(grib_accessor* a, int rank) if (last && last->accessor) { last->next_ = (grib_accessors_list*)grib_context_malloc_clear(c, sizeof(grib_accessors_list)); last->next_->accessor = a; - last->next_->prev_ = last; - last->next_->rank = rank; - this->last_ = last->next_; + last->next_->prev_ = last; + last->next_->rank_ = rank; + this->last_ = last->next_; } else { this->accessor = a; - this->rank = rank; - this->last_ = this; + this->rank_ = rank; + this->last_ = this; } } diff --git a/src/accessor/grib_accessors_list.h b/src/accessor/grib_accessors_list.h index 2bdd29de7..e136d955a 100644 --- a/src/accessor/grib_accessors_list.h +++ b/src/accessor/grib_accessors_list.h @@ -26,11 +26,14 @@ public: int unpack_float(float* val, size_t* buffer_len); int unpack_string(char** val, size_t* buffer_len); + int rank() const { return rank_; } + grib_accessor* accessor = nullptr; - int rank = 0; grib_accessors_list* next_ = nullptr; grib_accessors_list* prev_ = nullptr; grib_accessors_list* last_ = nullptr; +private: + int rank_ = 0; }; grib_accessors_list* grib_accessors_list_create(grib_context* c); diff --git a/src/grib_query.cc b/src/grib_query.cc index 29e3e1322..a1209efaf 100644 --- a/src/grib_query.cc +++ b/src/grib_query.cc @@ -384,7 +384,7 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces accessor_result = al->accessor; } if (accessor_result) { - result->push(accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } al = al->next_; @@ -398,7 +398,7 @@ static void search_from_accessors_list(grib_accessors_list* al, const grib_acces accessor_result = al->accessor; } if (accessor_result) { - result->push(accessor_result, al->rank); + result->push(accessor_result, al->rank()); } } } @@ -453,7 +453,7 @@ static void grib_find_same_and_push(grib_accessors_list* al, grib_accessor* a) { if (a) { grib_find_same_and_push(al, a->same); - al->push(a, al->rank); + al->push(a, al->rank()); } }