From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 1/6] vclock: allow to use const vclock as search key Date: Sun, 25 Nov 2018 16:48:08 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: vclockset_psearch() and friends never modify the vclock used as a search key, but the compiler will not allow to pass const struct vclock to any of those functions. Fix this. --- src/box/vclock.c | 4 +++- src/box/vclock.h | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/box/vclock.c b/src/box/vclock.c index b5eb2800..3c4b3204 100644 --- a/src/box/vclock.c +++ b/src/box/vclock.c @@ -206,4 +206,6 @@ vclockset_node_compare(const struct vclock *a, const struct vclock *b) return res; } -rb_gen(, vclockset_, vclockset_t, struct vclock, link, vclockset_node_compare); +rb_gen_ext_key(, vclockset_, vclockset_t, struct vclock, link, + vclockset_node_compare, const struct vclock *, + vclockset_node_compare); diff --git a/src/box/vclock.h b/src/box/vclock.h index 111e2916..d90f5697 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -271,7 +271,8 @@ vclock_compare(const struct vclock *a, const struct vclock *b) * @brief vclockset - a set of vclocks */ typedef rb_tree(struct vclock) vclockset_t; -rb_proto(, vclockset_, vclockset_t, struct vclock); +rb_proto_ext_key(, vclockset_, vclockset_t, struct vclock, + const struct vclock *); /** * A proximity search in a set of vclock objects. @@ -283,7 +284,7 @@ rb_proto(, vclockset_, vclockset_t, struct vclock); * @return a vclock that <= than \a key */ static inline struct vclock * -vclockset_match(vclockset_t *set, struct vclock *key) +vclockset_match(vclockset_t *set, const struct vclock *key) { struct vclock *match = vclockset_psearch(set, key); /** -- 2.11.0