diff --git a/lib/skiplist.c b/lib/skiplist.c index a20fa23..3c13583 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -166,7 +166,7 @@ skiplist_lookup(struct skiplist *list, const char *key) int8_t level = list->level; while (level >= SKIPLIST_LEVEL_MIN) { - struct skiplist_node *fwd_node = cur_node->forward[level]; + struct skiplist_node *fwd_node = cur_node->forward[(size_t)level]; switch (op_search(list, fwd_node, key)) { case OP_FINISH: @@ -376,7 +376,7 @@ skiplist_put(struct qb_map *map, const char *key, const void *value) char *old_v; while ((update_level = level) >= SKIPLIST_LEVEL_MIN) { - struct skiplist_node *fwd_node = cur_node->forward[level]; + struct skiplist_node *fwd_node = cur_node->forward[(size_t)level]; switch (op_search(list, fwd_node, key)) { case OP_FINISH: @@ -396,14 +396,14 @@ skiplist_put(struct qb_map *map, const char *key, const void *value) level--; } - update[update_level] = cur_node; + update[(size_t)update_level] = cur_node; } new_node_level = skiplist_level_generate(); if (new_node_level > list->level) { for (level = list->level + 1; level <= new_node_level; level++) - update[level] = list->header; + update[(size_t)level] = list->header; list->level = new_node_level; } @@ -417,8 +417,8 @@ skiplist_put(struct qb_map *map, const char *key, const void *value) /* Drop @new_node into @list. */ for (level = SKIPLIST_LEVEL_MIN; level <= new_node_level; level++) { - new_node->forward[level] = update[level]->forward[level]; - update[level]->forward[level] = new_node; + new_node->forward[(size_t)level] = update[(size_t)level]->forward[(size_t)level]; + update[(size_t)level]->forward[(size_t)level] = new_node; } list->length++; @@ -435,7 +435,7 @@ skiplist_rm(struct qb_map *map, const char *key) skiplist_update_t update; while ((update_level = level) >= SKIPLIST_LEVEL_MIN) { - struct skiplist_node *fwd_node = cur_node->forward[level]; + struct skiplist_node *fwd_node = cur_node->forward[(size_t)level]; switch (op_search(list, fwd_node, key)) { case OP_GOTO_NEXT_NODE: @@ -447,7 +447,7 @@ skiplist_rm(struct qb_map *map, const char *key) break; } - update[update_level] = cur_node; + update[(size_t)update_level] = cur_node; } /* The immediate forward node should be the matching node... */ @@ -460,9 +460,9 @@ skiplist_rm(struct qb_map *map, const char *key) /* Splice found_node out of list. */ for (level = SKIPLIST_LEVEL_MIN; level <= list->level; level++) - if (update[level]->forward[level] == found_node) - update[level]->forward[level] = - found_node->forward[level]; + if (update[(size_t)level]->forward[(size_t)level] == found_node) + update[(size_t)level]->forward[(size_t)level] = + found_node->forward[(size_t)level]; skiplist_node_deref(found_node, list); @@ -471,7 +471,7 @@ skiplist_rm(struct qb_map *map, const char *key) * highest level. */ for (level = list->level; level >= SKIPLIST_LEVEL_MIN; level--) { - if (list->header->forward[level]) + if (list->header->forward[(size_t)level]) break; list->level--;