aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/hashtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/hashtab.c')
-rw-r--r--src/nvim/hashtab.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 95ae7a152c..951e72ea52 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -45,7 +45,7 @@ char hash_removed;
void hash_init(hashtab_T *ht)
{
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
- memset(ht, 0, sizeof(hashtab_T));
+ CLEAR_POINTER(ht);
ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1;
}
@@ -342,11 +342,13 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
hashitem_T *oldarray = keep_smallarray
? 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
- : xmalloc(sizeof(hashitem_T) * newsize);
-
- memset(newarray, 0, sizeof(hashitem_T) * newsize);
+ : 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