diff options
Diffstat (limited to 'src/nvim/hashtab.c')
-rw-r--r-- | src/nvim/hashtab.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 851e70caca..475666be5e 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file hashtab.c /// /// Handling of a hashtable with Vim-specific properties. @@ -26,12 +23,13 @@ #include <stdbool.h> #include <string.h> -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" +#include "nvim/func_attr.h" +#include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/types.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" // Magic value for algorithm that walks through the array. #define PERTURB_SHIFT 5 @@ -65,7 +63,7 @@ void hash_clear(hashtab_T *ht) /// Free the array of a hash table and all contained values. /// /// @param off the offset from start of value to start of key (@see hashitem_T). -void hash_clear_all(hashtab_T *ht, unsigned int off) +void hash_clear_all(hashtab_T *ht, unsigned off) { size_t todo = ht->ht_used; for (hashitem_T *hi = ht->ht_array; todo > 0; hi++) { @@ -207,7 +205,7 @@ int hash_add(hashtab_T *ht, char *key) hash_T hash = hash_hash(key); hashitem_T *hi = hash_lookup(ht, key, strlen(key), hash); if (!HASHITEM_EMPTY(hi)) { - internal_error("hash_add()"); + siemsg(_("E685: Internal error: hash_add(): duplicate key \"%s\""), key); return FAIL; } hash_add_item(ht, hi, key, hash); @@ -350,15 +348,15 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems) // so that copying is possible. hashitem_T temparray[HT_INIT_SIZE]; hashitem_T *oldarray = keep_smallarray - ? memcpy(temparray, ht->ht_smallarray, sizeof(temparray)) - : ht->ht_array; + ? memcpy(temparray, ht->ht_smallarray, sizeof(temparray)) + : ht->ht_array; if (newarray_is_small) { CLEAR_FIELD(ht->ht_smallarray); } hashitem_T *newarray = newarray_is_small - ? ht->ht_smallarray - : xcalloc(newsize, sizeof(hashitem_T)); + ? ht->ht_smallarray + : xcalloc(newsize, sizeof(hashitem_T)); // Move all the items from the old array to the new one, placing them in // the right spot. The new array won't have any removed items, thus this @@ -411,7 +409,7 @@ hash_T hash_hash(const char *key) hash_T hash = (uint8_t)(*key); if (hash == 0) { - return (hash_T)0; + return 0; } // A simplistic algorithm that appears to do very well. @@ -457,8 +455,8 @@ hash_T hash_hash_len(const char *key, const size_t len) /// /// Used for testing because luajit ffi does not allow getting addresses of /// globals. -const char_u *_hash_key_removed(void) +const char *_hash_key_removed(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - return (char_u *)HI_KEY_REMOVED; + return HI_KEY_REMOVED; } |