Skip to content
Snippets Groups Projects
Commit 68d8ccc7 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Define mh_key_t in mh_i32ptr_hash to enable mh_find().

parent 02f5afc6
No related branches found
No related tags found
No related merge requests found
...@@ -36,14 +36,17 @@ ...@@ -36,14 +36,17 @@
* Map: (i32) => (void *) * Map: (i32) => (void *)
*/ */
#define mh_name _i32ptr #define mh_name _i32ptr
#define mh_key_t uint32_t
struct mh_i32ptr_node_t { struct mh_i32ptr_node_t {
uint32_t key; mh_key_t key;
void *val; void *val;
}; };
#define mh_node_t struct mh_i32ptr_node_t #define mh_node_t struct mh_i32ptr_node_t
#define mh_arg_t void * #define mh_arg_t void *
#define mh_hash(a, arg) (a->key) #define mh_hash(a, arg) (a->key)
#define mh_hash_key(a, arg) (a)
#define mh_eq(a, b, arg) ((a->key) == (b->key)) #define mh_eq(a, b, arg) ((a->key) == (b->key))
#define mh_eq_key(a, b, arg) ((a) == (b->key))
#include <mhash.h> #include <mhash.h>
...@@ -121,8 +121,7 @@ space_delete(struct space *space) ...@@ -121,8 +121,7 @@ space_delete(struct space *space)
{ {
if (tarantool_L) if (tarantool_L)
box_lua_space_delete(tarantool_L, space); box_lua_space_delete(tarantool_L, space);
const struct mh_i32ptr_node_t node = { space_id(space), NULL }; mh_int_t k = mh_i32ptr_find(spaces, space_id(space), NULL);
mh_int_t k = mh_i32ptr_get(spaces, &node, NULL);
assert(k != mh_end(spaces)); assert(k != mh_end(spaces));
mh_i32ptr_del(spaces, k, NULL); mh_i32ptr_del(spaces, k, NULL);
for (uint32_t j = 0 ; j <= space->index_id_max; j++) for (uint32_t j = 0 ; j <= space->index_id_max; j++)
...@@ -134,8 +133,7 @@ space_delete(struct space *space) ...@@ -134,8 +133,7 @@ space_delete(struct space *space)
struct space * struct space *
space_by_id(uint32_t id) space_by_id(uint32_t id)
{ {
const struct mh_i32ptr_node_t node = { id, NULL }; mh_int_t space = mh_i32ptr_find(spaces, id, NULL);
mh_int_t space = mh_i32ptr_get(spaces, &node, NULL);
if (space == mh_end(spaces)) if (space == mh_end(spaces))
return NULL; return NULL;
return (struct space *) mh_i32ptr_node(spaces, space)->val; return (struct space *) mh_i32ptr_node(spaces, space)->val;
......
...@@ -321,8 +321,7 @@ fiber_ready_async(ev_async *watcher, int revents) ...@@ -321,8 +321,7 @@ fiber_ready_async(ev_async *watcher, int revents)
struct fiber * struct fiber *
fiber_find(uint32_t fid) fiber_find(uint32_t fid)
{ {
struct mh_i32ptr_node_t node = { fid, NULL }; mh_int_t k = mh_i32ptr_find(fiber_registry, fid, NULL);
mh_int_t k = mh_i32ptr_get(fiber_registry, &node, NULL);
if (k == mh_end(fiber_registry)) if (k == mh_end(fiber_registry))
return NULL; return NULL;
......
...@@ -93,8 +93,7 @@ session_destroy(uint32_t sid) ...@@ -93,8 +93,7 @@ session_destroy(uint32_t sid)
int int
session_fd(uint32_t sid) session_fd(uint32_t sid)
{ {
struct mh_i32ptr_node_t node = { sid, NULL }; mh_int_t k = mh_i32ptr_find(session_registry, sid, NULL);
mh_int_t k = mh_i32ptr_get(session_registry, &node, NULL);
return k == mh_end(session_registry) ? return k == mh_end(session_registry) ?
-1 : (intptr_t) mh_i32ptr_node(session_registry, k)->val; -1 : (intptr_t) mh_i32ptr_node(session_registry, k)->val;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment