diff --git a/client/tarantool_checksum/tc_file.c b/client/tarantool_checksum/tc_file.c index fff98356c92e4d978f89803c83cb8dfb8809a902..5c19bd1757613eb96eb51539bb079e08282a137b 100644 --- a/client/tarantool_checksum/tc_file.c +++ b/client/tarantool_checksum/tc_file.c @@ -194,7 +194,7 @@ int tc_file_load(struct tc_spaces *s, char *file, } const struct tc_key *node = k; mh_int_t pos = mh_pk_put(space->hash_log, &node, NULL, - space, space); + space); if (pos == mh_end(space->hash_log)) { fclose(f); return -1; @@ -211,7 +211,7 @@ int tc_file_load(struct tc_spaces *s, char *file, } const struct tc_key *node = k; mh_int_t pos = mh_pk_put(space->hash_snap, &node, - NULL, space, space); + NULL, space); if (pos == mh_end(space->hash_log)) { fclose(f); return -1; diff --git a/client/tarantool_checksum/tc_generate.c b/client/tarantool_checksum/tc_generate.c index a11677d7e3556367392ad4e38570b6ef2e4381a0..214585db749f0f678ac8d434c6f3c2da97433c31 100644 --- a/client/tarantool_checksum/tc_generate.c +++ b/client/tarantool_checksum/tc_generate.c @@ -226,7 +226,7 @@ tc_generate_entry(struct tc_spaces *s, struct tnt_request *r) } /* 3. put into hash */ const struct tc_key *node = k; - mh_int_t pos = mh_pk_put(space->hash_log, &node, NULL, space, space); + mh_int_t pos = mh_pk_put(space->hash_log, &node, NULL, space); if (pos == mh_end(space->hash_log)) { free(k); return -1; @@ -373,7 +373,7 @@ tc_generate_snaprow(struct tc_spaces *s, struct tnt_iter_storage *is, /* foreach snapshot row which does not exist in index dump: * calculate crc and add to the index */ const struct tc_key *node = k; - mh_int_t pos = mh_pk_get(space->hash_log, &node, space, space); + mh_int_t pos = mh_pk_get(space->hash_log, &node, space); const struct tc_key *v = NULL; if (pos != mh_end(space->hash_log)) v = *mh_pk_node(space->hash_log, pos); @@ -381,7 +381,7 @@ tc_generate_snaprow(struct tc_spaces *s, struct tnt_iter_storage *is, k->crc = crc32c(0, (unsigned char*)is->t.data, is->t.size); const struct tc_key *node = k; mh_int_t pos = mh_pk_put(space->hash_snap, &node, NULL, - space, space); + space); if (pos == mh_end(space->hash_snap)) { free(k); return -1; diff --git a/client/tarantool_checksum/tc_hash.h b/client/tarantool_checksum/tc_hash.h index 3f8694a56d2b43e3a7acbbe8adea94fec3e26526..23b1030660d5afa0cdb205eaed7bb64816ff3945 100644 --- a/client/tarantool_checksum/tc_hash.h +++ b/client/tarantool_checksum/tc_hash.h @@ -14,9 +14,8 @@ struct mh_u32ptr_node_t { }; #define mh_node_t struct mh_u32ptr_node_t -#define mh_hash_arg_t void * +#define mh_arg_t void * #define mh_hash(a, arg) (a->key) -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) ((a->key) == (b->key)) #include <mhash.h> @@ -32,9 +31,8 @@ search_equal(const struct tc_key *a, const struct tc_key *b, #define mh_name _pk #define mh_node_t struct tc_key * -#define mh_hash_arg_t struct tc_space * +#define mh_arg_t struct tc_space * #define mh_hash(a, arg) search_hash(*(a), arg) -#define mh_eq_arg_t struct tc_space * #define mh_eq(a, b, arg) search_equal(*(a), *(b), arg) #include <mhash.h> diff --git a/client/tarantool_checksum/tc_space.c b/client/tarantool_checksum/tc_space.c index d32e060414e39310396e8433a5818b4d9ed9eafe..f7697f69dceff5c2f9ad88723f341a39fb59fbd5 100644 --- a/client/tarantool_checksum/tc_space.c +++ b/client/tarantool_checksum/tc_space.c @@ -54,7 +54,7 @@ void tc_space_free(struct tc_spaces *s) mh_int_t i; mh_foreach(s->t, i) { struct tc_space *space = mh_u32ptr_node(s->t, i)->val; - mh_u32ptr_del(s->t, i, NULL, NULL); + mh_u32ptr_del(s->t, i, NULL); mh_int_t pos = 0; while (pos != mh_end(space->hash_log)) { @@ -94,13 +94,13 @@ struct tc_space *tc_space_create(struct tc_spaces *s, uint32_t id) { space->hash_snap = mh_pk_new(); const struct mh_u32ptr_node_t node = { .key = space->id, .val = space }; - mh_u32ptr_put(s->t, &node, NULL, space, space); + mh_u32ptr_put(s->t, &node, NULL, space); return space; } struct tc_space *tc_space_match(struct tc_spaces *s, uint32_t id) { const struct mh_u32ptr_node_t node = { .key = id }; - mh_int_t k = mh_u32ptr_get(s->t, &node, NULL, NULL); + mh_int_t k = mh_u32ptr_get(s->t, &node, NULL); struct tc_space *space = NULL; if (k != mh_end(s->t)) space = mh_u32ptr_node(s->t, k)->val; diff --git a/client/tarantool_checksum/tc_verify.c b/client/tarantool_checksum/tc_verify.c index aac9ba84a65c476287bed0ca5d10e64c3f70dab5..5ff94c6ded4cbe584d76ed50e4e3362c003522bc 100644 --- a/client/tarantool_checksum/tc_verify.c +++ b/client/tarantool_checksum/tc_verify.c @@ -74,7 +74,7 @@ int tc_verify_cmp(struct tc_spaces *s, /* 1. check in hash, if found then skip */ const struct tc_key *node = k; - mh_int_t pos = mh_pk_get(space->hash_log, &node, space, space); + mh_int_t pos = mh_pk_get(space->hash_log, &node, space); const struct tc_key *v = NULL; if (pos != mh_end(space->hash_log)) v = *mh_pk_node(space->hash_log, pos); @@ -85,7 +85,7 @@ int tc_verify_cmp(struct tc_spaces *s, /* 2. if key was not found in xlog hash, then try snapshot hash */ node = k; - pos = mh_pk_get(space->hash_snap, &node, space, space); + pos = mh_pk_get(space->hash_snap, &node, space); v = NULL; if (pos != mh_end(space->hash_snap)) v = *mh_pk_node(space->hash_snap, pos); diff --git a/include/assoc.h b/include/assoc.h index 497e12ecfc436494988f013ea2c175b1253823ad..e5e5851fee8681ab79fdb9405108529b35602c32 100644 --- a/include/assoc.h +++ b/include/assoc.h @@ -44,9 +44,8 @@ struct mh_i32ptr_node_t { }; #define mh_node_t struct mh_i32ptr_node_t -#define mh_hash_arg_t void * +#define mh_arg_t void * #define mh_hash(a, arg) (a->key) -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) ((a->key) == (b->key)) #include <mhash.h> @@ -62,9 +61,8 @@ struct mh_i64ptr_node_t { #define mh_node_t struct mh_i64ptr_node_t #define mh_int_t u32 -#define mh_hash_arg_t void * +#define mh_arg_t void * #define mh_hash(a, arg) ((u32)((a->key)>>33^(a->key)^(a->key)<<11)) -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) ((a->key) == (b->key)) #include <mhash.h> @@ -91,15 +89,14 @@ struct mh_lstrptr_node_t { #define mh_node_t struct mh_lstrptr_node_t #define mh_int_t u32 -#define mh_hash_arg_t void * +#define mh_arg_t void * static inline u32 -mh_strptr_hash(const mh_node_t *a, mh_hash_arg_t arg) { +mh_strptr_hash(const mh_node_t *a, mh_arg_t arg) { (void) arg; const void *_k = (a->key); const u32 l = load_varint32(&_k); return PMurHash32(13, _k, l); } #define mh_hash(a, arg) mh_strptr_hash(a, arg) -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) (lstrcmp(a->key, b->key) == 0) #include <mhash.h> diff --git a/include/mhash.h b/include/mhash.h index 9dd7ed8db38557c7d41409104c50e3935312201f..ec8899e99a90146552055445fc8f79825f39e2c9 100644 --- a/include/mhash.h +++ b/include/mhash.h @@ -144,17 +144,17 @@ struct _mh(t) { struct _mh(t) * _mh(new)(); void _mh(clear)(struct _mh(t) *h); void _mh(delete)(struct _mh(t) *h); -void _mh(resize)(struct _mh(t) *h, mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg); +void _mh(resize)(struct _mh(t) *h, mh_arg_t arg); int _mh(start_resize)(struct _mh(t) *h, mh_int_t buckets, mh_int_t batch, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg); + mh_arg_t arg); void _mh(reserve)(struct _mh(t) *h, mh_int_t size, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg); + mh_arg_t arg); void __attribute__((noinline)) _mh(del_resize)(struct _mh(t) *h, mh_int_t x, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg); + mh_arg_t arg); void _mh(dump)(struct _mh(t) *h); -#define put_slot(h, node, hash_arg, eq_arg) \ - _mh(put_slot)(h, node, hash_arg, eq_arg) +#define put_slot(h, node, arg) \ + _mh(put_slot)(h, node, arg) static inline mh_node_t * _mh(node)(struct _mh(t) *h, mh_int_t x) @@ -172,16 +172,15 @@ _mh(next_slot)(mh_int_t slot, mh_int_t inc, mh_int_t size) static inline mh_int_t _mh(get)(struct _mh(t) *h, const mh_node_t *node, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { - (void) hash_arg; - (void) eq_arg; + (void) arg; - mh_int_t k = mh_hash(node, hash_arg); + mh_int_t k = mh_hash(node, arg); mh_int_t i = k % h->n_buckets; mh_int_t inc = 1 + k % (h->n_buckets - 1); for (;;) { - if ((mh_exist(h, i) && mh_eq(node, mh_node(h, i), eq_arg))) + if ((mh_exist(h, i) && mh_eq(node, mh_node(h, i), arg))) return i; if (!mh_dirty(h, i)) @@ -193,18 +192,17 @@ _mh(get)(struct _mh(t) *h, const mh_node_t *node, static inline mh_int_t _mh(put_slot)(struct _mh(t) *h, const mh_node_t *node, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { - (void) hash_arg; - (void) eq_arg; + (void) arg; - mh_int_t k = mh_hash(node, hash_arg); /* hash key */ + mh_int_t k = mh_hash(node, arg); /* hash key */ mh_int_t i = k % h->n_buckets; /* offset in the hash table. */ mh_int_t inc = 1 + k % (h->n_buckets - 1); /* overflow chain increment. */ /* Skip through all collisions. */ while (mh_exist(h, i)) { - if (mh_eq(node, mh_node(h, i), eq_arg)) + if (mh_eq(node, mh_node(h, i), arg)) return i; /* Found a duplicate. */ /* * Mark this link as part of a collision chain. The @@ -227,7 +225,7 @@ _mh(put_slot)(struct _mh(t) *h, const mh_node_t *node, while (mh_dirty(h, i)) { i = _mh(next_slot)(i, inc, h->n_buckets); - if (mh_exist(h, i) && mh_eq(mh_node(h, i), node, eq_arg)) + if (mh_exist(h, i) && mh_eq(mh_node(h, i), node, arg)) return i; /* Found a duplicate. */ } /* Reached the end of the collision chain: no duplicates. */ @@ -245,7 +243,7 @@ _mh(put_slot)(struct _mh(t) *h, const mh_node_t *node, */ static inline mh_int_t _mh(put)(struct _mh(t) *h, const mh_node_t *node, mh_node_t **ret, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { mh_int_t x = mh_end(h); if (h->size == h->n_buckets) @@ -254,22 +252,22 @@ _mh(put)(struct _mh(t) *h, const mh_node_t *node, mh_node_t **ret, #if MH_INCREMENTAL_RESIZE if (mh_unlikely(h->resize_position > 0)) - _mh(resize)(h, hash_arg, eq_arg); + _mh(resize)(h, arg); else if (mh_unlikely(h->n_dirty >= h->upper_bound)) { - if (_mh(start_resize)(h, h->n_buckets + 1, 0, hash_arg, eq_arg)) + if (_mh(start_resize)(h, h->n_buckets + 1, 0, arg)) goto put_done; } if (h->resize_position) - _mh(put)(h->shadow, node, NULL, hash_arg, eq_arg); + _mh(put)(h->shadow, node, NULL, arg); #else if (mh_unlikely(h->n_dirty >= h->upper_bound)) { if (_mh(start_resize)(h, h->n_buckets + 1, h->size, - hash_arg, eq_arg)) + arg)) goto put_done; } #endif - x = put_slot(h, node, hash_arg, eq_arg); + x = put_slot(h, node, arg); int exist = mh_exist(h, x); if (!exist) { @@ -295,7 +293,7 @@ _mh(put)(struct _mh(t) *h, const mh_node_t *node, mh_node_t **ret, static inline void _mh(del)(struct _mh(t) *h, mh_int_t x, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { if (x != h->n_buckets && mh_exist(h, x)) { mh_setfree(h, x); @@ -304,7 +302,7 @@ _mh(del)(struct _mh(t) *h, mh_int_t x, h->n_dirty--; #if MH_INCREMENTAL_RESIZE if (mh_unlikely(h->resize_position)) - _mh(del_resize)(h, x, hash_arg, eq_arg); + _mh(del_resize)(h, x, arg); #endif } } @@ -312,24 +310,24 @@ _mh(del)(struct _mh(t) *h, mh_int_t x, static inline void _mh(remove)(struct _mh(t) *h, const mh_node_t *node, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { - mh_int_t k = _mh(get)(h, node, hash_arg, eq_arg); + mh_int_t k = _mh(get)(h, node, arg); if (k != mh_end(h)) - _mh(del)(h, k, hash_arg, eq_arg); + _mh(del)(h, k, arg); } #ifdef MH_SOURCE void __attribute__((noinline)) _mh(del_resize)(struct _mh(t) *h, mh_int_t x, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { struct _mh(t) *s = h->shadow; uint32_t y = _mh(get)(s, (const mh_node_t *) &(h->p[x]), - hash_arg, eq_arg); - _mh(del)(s, y, hash_arg, eq_arg); - _mh(resize)(h, hash_arg, eq_arg); + arg); + _mh(del)(s, y, arg); + _mh(resize)(h, arg); } struct _mh(t) * @@ -366,7 +364,7 @@ _mh(delete)(struct _mh(t) *h) void _mh(resize)(struct _mh(t) *h, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { struct _mh(t) *s = h->shadow; #if MH_INCREMENTAL_RESIZE @@ -381,7 +379,7 @@ _mh(resize)(struct _mh(t) *h, #endif if (!mh_exist(h, i)) continue; - mh_int_t n = put_slot(s, mh_node(h, i), hash_arg, eq_arg); + mh_int_t n = put_slot(s, mh_node(h, i), arg); s->p[n] = h->p[i]; mh_setexist(s, n); s->n_dirty++; @@ -395,7 +393,7 @@ _mh(resize)(struct _mh(t) *h, int _mh(start_resize)(struct _mh(t) *h, mh_int_t buckets, mh_int_t batch, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { if (h->resize_position) { /* resize has already been started */ @@ -436,16 +434,16 @@ _mh(start_resize)(struct _mh(t) *h, mh_int_t buckets, mh_int_t batch, s->p = NULL; return -1; } - _mh(resize)(h, hash_arg, eq_arg); + _mh(resize)(h, arg); return 0; } void _mh(reserve)(struct _mh(t) *h, mh_int_t size, - mh_hash_arg_t hash_arg, mh_eq_arg_t eq_arg) + mh_arg_t arg) { - _mh(start_resize)(h, size/MH_DENSITY, h->size, hash_arg, eq_arg); + _mh(start_resize)(h, size/MH_DENSITY, h->size, arg); } #ifndef mh_stat @@ -492,8 +490,7 @@ _mh(dump)(struct _mh(t) *h) #undef MH_HEADER #undef mh_int_t #undef mh_node_t -#undef mh_hash_arg_t -#undef mh_eq_arg_t +#undef mh_arg_t #undef mh_name #undef mh_hash #undef mh_eq diff --git a/src/box/hash_index.m b/src/box/hash_index.m index 221d0eab64a780f87fa30e16275d1ac020ba9fa4..5494f60fb4f3f849cfe1b1f046edcc74006eb130 100644 --- a/src/box/hash_index.m +++ b/src/box/hash_index.m @@ -284,7 +284,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) - (void) reserve: (u32) n_tuples { - mh_i32ptr_reserve(int_hash, n_tuples, NULL, NULL); + mh_i32ptr_reserve(int_hash, n_tuples, NULL); } - (void) free @@ -318,7 +318,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct tuple *ret = NULL; struct mh_i32ptr_node_t node = int32_key_to_node(key); - mh_int_t k = mh_i32ptr_get(int_hash, &node, NULL, NULL); + mh_int_t k = mh_i32ptr_get(int_hash, &node, NULL); if (k != mh_end(int_hash)) ret = mh_i32ptr_node(int_hash, k)->val; #ifdef DEBUG @@ -338,11 +338,11 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct mh_i32ptr_node_t *dup_node = &old_node; new_node = int32_tuple_to_node(new_tuple, key_def); mh_int_t pos = mh_i32ptr_put(int_hash, &new_node, - &dup_node, NULL, NULL); + &dup_node, NULL); ERROR_INJECT(ERRINJ_INDEX_ALLOC, { - mh_i32ptr_del(int_hash, pos, NULL, NULL); + mh_i32ptr_del(int_hash, pos, NULL); pos = mh_end(int_hash); }); @@ -354,10 +354,10 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) errcode = replace_check_dup(old_tuple, dup_tuple, mode); if (errcode) { - mh_i32ptr_remove(int_hash, &new_node, NULL, NULL); + mh_i32ptr_remove(int_hash, &new_node, NULL); if (dup_node) { pos = mh_i32ptr_put(int_hash, dup_node, - NULL, NULL, NULL); + NULL, NULL); if (pos == mh_end(int_hash)) { panic("Failed to allocate memory in " "recover of int hash"); @@ -370,7 +370,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) } if (old_tuple) { old_node = int32_tuple_to_node(old_tuple, key_def); - mh_i32ptr_remove(int_hash, &old_node, NULL, NULL); + mh_i32ptr_remove(int_hash, &old_node, NULL); } return old_tuple; } @@ -400,7 +400,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node = int32_key_to_node(key); - it->h_pos = mh_i32ptr_get(int_hash, &node, NULL, NULL); + it->h_pos = mh_i32ptr_get(int_hash, &node, NULL); it->base.next = hash_iterator_i32_ge; break; } @@ -413,7 +413,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node = int32_key_to_node(key); - it->h_pos = mh_i32ptr_get(int_hash, &node, NULL, NULL); + it->h_pos = mh_i32ptr_get(int_hash, &node, NULL); it->base.next = hash_iterator_i32_eq; break; default: @@ -450,7 +450,7 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) @implementation Hash64Index - (void) reserve: (u32) n_tuples { - mh_i64ptr_reserve(int64_hash, n_tuples, NULL, NULL); + mh_i64ptr_reserve(int64_hash, n_tuples, NULL); } - (void) free @@ -481,7 +481,7 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct tuple *ret = NULL; struct mh_i64ptr_node_t node = int64_key_to_node(key); - mh_int_t k = mh_i64ptr_get(int64_hash, &node, NULL, NULL); + mh_int_t k = mh_i64ptr_get(int64_hash, &node, NULL); if (k != mh_end(int64_hash)) ret = mh_i64ptr_node(int64_hash, k)->val; #ifdef DEBUG @@ -501,11 +501,11 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct mh_i64ptr_node_t *dup_node = &old_node; new_node = int64_tuple_to_node(new_tuple, key_def); mh_int_t pos = mh_i64ptr_put(int64_hash, &new_node, - &dup_node, NULL, NULL); + &dup_node, NULL); ERROR_INJECT(ERRINJ_INDEX_ALLOC, { - mh_i64ptr_del(int64_hash, pos, NULL, NULL); + mh_i64ptr_del(int64_hash, pos, NULL); pos = mh_end(int64_hash); }); if (pos == mh_end(int64_hash)) { @@ -516,10 +516,10 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) errcode = replace_check_dup(old_tuple, dup_tuple, mode); if (errcode) { - mh_i64ptr_remove(int64_hash, &new_node, NULL, NULL); + mh_i64ptr_remove(int64_hash, &new_node, NULL); if (dup_node) { pos = mh_i64ptr_put(int64_hash, dup_node, - NULL, NULL, NULL); + NULL, NULL); if (pos == mh_end(int64_hash)) { panic("Failed to allocate memory in " "recover of int64 hash"); @@ -532,7 +532,7 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) } if (old_tuple) { old_node = int64_tuple_to_node(old_tuple, key_def); - mh_i64ptr_remove(int64_hash, &old_node, NULL, NULL); + mh_i64ptr_remove(int64_hash, &old_node, NULL); } return old_tuple; } @@ -564,7 +564,7 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node = int64_key_to_node(key); - it->h_pos = mh_i64ptr_get(int64_hash, &node, NULL, NULL); + it->h_pos = mh_i64ptr_get(int64_hash, &node, NULL); it->base.next = hash_iterator_i64_ge; break; } @@ -577,7 +577,7 @@ int64_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node = int64_key_to_node(key); - it->h_pos = mh_i64ptr_get(int64_hash, &node, NULL, NULL); + it->h_pos = mh_i64ptr_get(int64_hash, &node, NULL); it->base.next = hash_iterator_i64_eq; break; default: @@ -608,7 +608,7 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) @implementation HashStrIndex - (void) reserve: (u32) n_tuples { - mh_lstrptr_reserve(str_hash, n_tuples, NULL, NULL); + mh_lstrptr_reserve(str_hash, n_tuples, NULL); } - (void) free @@ -639,7 +639,7 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct tuple *ret = NULL; const struct mh_lstrptr_node_t node = { .key = key }; - mh_int_t k = mh_lstrptr_get(str_hash, &node, NULL, NULL); + mh_int_t k = mh_lstrptr_get(str_hash, &node, NULL); if (k != mh_end(str_hash)) ret = mh_lstrptr_node(str_hash, k)->val; #ifdef DEBUG @@ -661,11 +661,11 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) struct mh_lstrptr_node_t *dup_node = &old_node; new_node = lstrptr_tuple_to_node(new_tuple, key_def); mh_int_t pos = mh_lstrptr_put(str_hash, &new_node, - &dup_node, NULL, NULL); + &dup_node, NULL); ERROR_INJECT(ERRINJ_INDEX_ALLOC, { - mh_lstrptr_del(str_hash, pos, NULL, NULL); + mh_lstrptr_del(str_hash, pos, NULL); pos = mh_end(str_hash); }); @@ -677,10 +677,10 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) errcode = replace_check_dup(old_tuple, dup_tuple, mode); if (errcode) { - mh_lstrptr_remove(str_hash, &new_node, NULL, NULL); + mh_lstrptr_remove(str_hash, &new_node, NULL); if (dup_node) { pos = mh_lstrptr_put(str_hash, dup_node, - NULL, NULL, NULL); + NULL, NULL); if (pos == mh_end(str_hash)) { panic("Failed to allocate memory in " "recover of str hash"); @@ -693,7 +693,7 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) } if (old_tuple) { old_node = lstrptr_tuple_to_node(old_tuple, key_def); - mh_lstrptr_remove(str_hash, &old_node, NULL, NULL); + mh_lstrptr_remove(str_hash, &old_node, NULL); } return old_tuple; } @@ -726,7 +726,7 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node.key = key; - it->h_pos = mh_lstrptr_get(str_hash, &node, NULL, NULL); + it->h_pos = mh_lstrptr_get(str_hash, &node, NULL); it->base.next = hash_iterator_lstr_ge; break; } @@ -739,7 +739,7 @@ lstrptr_tuple_to_node(struct tuple *tuple, struct key_def *key_def) check_key_parts(key_def, part_count, traits->allows_partial_key); node.key = key; - it->h_pos = mh_lstrptr_get(str_hash, &node, NULL, NULL); + it->h_pos = mh_lstrptr_get(str_hash, &node, NULL); it->base.next = hash_iterator_lstr_eq; break; default: diff --git a/src/box/space.m b/src/box/space.m index 22b3a8981285ddd3371d25914d6fd626f6dc5232..8e3add764af794839d6c6f4692875a4d3717ef37 100644 --- a/src/box/space.m +++ b/src/box/space.m @@ -54,7 +54,7 @@ space_create(i32 space_no, struct key_def *key_defs, int key_count, int arity) space->no = space_no; const struct mh_i32ptr_node_t node = { .key = space->no, .val = space }; - mh_i32ptr_put(spaces, &node, NULL, NULL, NULL); + mh_i32ptr_put(spaces, &node, NULL, NULL); space->arity = arity; space->key_defs = key_defs; @@ -69,7 +69,7 @@ struct space * space_by_n(i32 n) { const struct mh_i32ptr_node_t node = { .key = n }; - mh_int_t space = mh_i32ptr_get(spaces, &node, NULL, NULL); + mh_int_t space = mh_i32ptr_get(spaces, &node, NULL); if (space == mh_end(spaces)) return NULL; return mh_i32ptr_node(spaces, space)->val; @@ -195,7 +195,7 @@ space_free(void) mh_foreach(spaces, i) { struct space *space = mh_i32ptr_node(spaces, i)->val; - mh_i32ptr_del(spaces, i, NULL, NULL); + mh_i32ptr_del(spaces, i, NULL); int j; for (j = 0 ; j < space->key_count; j++) { @@ -376,7 +376,7 @@ space_config() const struct mh_i32ptr_node_t node = { .key = space->no, .val = space }; - mh_i32ptr_put(spaces, &node, NULL, NULL, NULL); + mh_i32ptr_put(spaces, &node, NULL, NULL); say_info("space %i successfully configured", i); } } diff --git a/src/fiber.m b/src/fiber.m index 6bdae1ae9ff8b2f3adaf9c6e2cb7d39e07154c21..9b6a06e46c0f48d40fc07acff603004e7bd051d7 100644 --- a/src/fiber.m +++ b/src/fiber.m @@ -302,7 +302,7 @@ struct fiber * fiber_find(int fid) { struct mh_i32ptr_node_t node = { .key = fid }; - mh_int_t k = mh_i32ptr_get(fiber_registry, &node, NULL, NULL); + mh_int_t k = mh_i32ptr_get(fiber_registry, &node, NULL); if (k == mh_end(fiber_registry)) return NULL; @@ -313,14 +313,14 @@ static void register_fid(struct fiber *fiber) { struct mh_i32ptr_node_t node = { .key = fiber -> fid, .val = fiber }; - mh_i32ptr_put(fiber_registry, &node, NULL, NULL, NULL); + mh_i32ptr_put(fiber_registry, &node, NULL, NULL); } static void unregister_fid(struct fiber *fiber) { struct mh_i32ptr_node_t node = { .key = fiber->fid }; - mh_i32ptr_remove(fiber_registry, &node, NULL, NULL); + mh_i32ptr_remove(fiber_registry, &node, NULL); } void diff --git a/src/session.m b/src/session.m index 9640fe8832ea10a888f3665d628f40e16eddd478..034c44d97818e307af1fd22785307a7a5d61a9dd 100644 --- a/src/session.m +++ b/src/session.m @@ -51,7 +51,7 @@ session_create(int fd) .key = sid, .val = (void *) (intptr_t) fd }; - mh_int_t k = mh_i32ptr_put(session_registry, &node, NULL, NULL, NULL); + mh_int_t k = mh_i32ptr_put(session_registry, &node, NULL, NULL); if (k == mh_end(session_registry)) { tnt_raise(ClientError, :ER_MEMORY_ISSUE, @@ -68,8 +68,7 @@ session_create(int fd) session_on_connect.trigger(param); } @catch (tnt_Exception *e) { fiber_set_sid(fiber, 0); - mh_i32ptr_remove(session_registry, &node, - NULL, NULL); + mh_i32ptr_remove(session_registry, &node, NULL); @throw; } } @@ -94,14 +93,14 @@ session_destroy(uint32_t sid) } } struct mh_i32ptr_node_t node = { .key = sid }; - mh_i32ptr_remove(session_registry, &node, NULL, NULL); + mh_i32ptr_remove(session_registry, &node, NULL); } int session_fd(uint32_t sid) { struct mh_i32ptr_node_t node = { .key = sid }; - mh_int_t k = mh_i32ptr_get(session_registry, &node, NULL, NULL); + mh_int_t k = mh_i32ptr_get(session_registry, &node, NULL); return k == mh_end(session_registry) ? -1 : (intptr_t) mh_i32ptr_node(session_registry, k)->val; } diff --git a/test/unit/mhash.c b/test/unit/mhash.c index e2c2ca09ff087dd3182e5ba14ad7ad6e800bd116..2cf9ff7c843858e44b6814b47fddbae9c8ee6f7c 100644 --- a/test/unit/mhash.c +++ b/test/unit/mhash.c @@ -10,9 +10,8 @@ struct mh_i32_node_t { int32_t val; }; #define mh_node_t struct mh_i32_node_t -#define mh_hash_arg_t void * +#define mh_arg_t void * #define mh_hash(a, arg) (a->key) -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) ((a->key) == (b->key)) #include "mhash.h" @@ -22,9 +21,8 @@ struct mh_i32_collision_node_t { int32_t val; }; #define mh_node_t struct mh_i32_collision_node_t -#define mh_hash_arg_t void * +#define mh_arg_t void * #define mh_hash(a, arg) 42 -#define mh_eq_arg_t void * #define mh_eq(a, b, arg) ((a->key) == (b->key)) #include "mhash.h" @@ -34,23 +32,23 @@ struct mh_i32_collision_node_t { static void mhash_int32_id_test() { header(); - int ret, k; + int k; struct mh_i32_t *h; #define init() ({ mh_i32_new(); }) #define clear(x) ({ mh_i32_clear((x)); }) #define destroy(x) ({ mh_i32_delete((x)); }) #define get(x) ({ \ - const struct mh_i32_node_t _node = { .key = (x) }; \ - mh_i32_get(h, &_node, NULL, NULL); \ + const struct mh_i32_node_t _node = { .key = (x) }; \ + mh_i32_get(h, &_node, NULL); \ }) #define put(x) ({ \ - const struct mh_i32_node_t _node = { .key = (x) }; \ - mh_i32_put(h, &_node, NULL, NULL, &ret); \ + const struct mh_i32_node_t _node = { .key = (x) }; \ + mh_i32_put(h, &_node, NULL, NULL); \ }) #define key(k) (mh_i32_node(h, k)->key) #define val(k) (mh_i32_node(h, k)->val) #define del(k) ({ \ - mh_i32_del(h, k, NULL, NULL); \ + mh_i32_del(h, k, NULL); \ }) #include "mhash_body.c" @@ -61,23 +59,23 @@ static void mhash_int32_id_test() static void mhash_int32_collision_test() { header(); - int ret, k; + int k; struct mh_i32_collision_t *h; #define init() ({ mh_i32_collision_new(); }) #define clear(x) ({ mh_i32_collision_clear((x)); }) #define destroy(x) ({ mh_i32_collision_delete((x)); }) #define get(x) ({ \ const struct mh_i32_collision_node_t _node = { .key = (x) }; \ - mh_i32_collision_get(h, &_node, NULL, NULL); \ + mh_i32_collision_get(h, &_node, NULL); \ }) #define put(x) ({ \ const struct mh_i32_collision_node_t _node = { .key = (x) }; \ - mh_i32_collision_put(h, &_node, NULL, NULL, &ret); \ + mh_i32_collision_put(h, &_node, NULL, NULL); \ }) #define key(k) (mh_i32_collision_node(h, k)->key) #define val(k) (mh_i32_collision_node(h, k)->val) #define del(k) ({ \ - mh_i32_collision_del(h, k, NULL, NULL); \ + mh_i32_collision_del(h, k, NULL); \ }) #include "mhash_body.c"