summaryrefslogtreecommitdiffstats
path: root/src/hashtab.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-12 19:37:17 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-12 19:37:17 +0200
commita80faa8930ed5a554beeb2727762538873135e83 (patch)
treee797605e0c781214543fcba103cffede7af611cd /src/hashtab.c
parent82de464f763d6e6d89229be03ce7c6d02fd5fb59 (diff)
patch 8.2.0559: clearing a struct is verbosev8.2.0559
Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER().
Diffstat (limited to 'src/hashtab.c')
-rw-r--r--src/hashtab.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/hashtab.c b/src/hashtab.c
index f43469fc34..816dcf7933 100644
--- a/src/hashtab.c
+++ b/src/hashtab.c
@@ -65,7 +65,7 @@ hash_create(void)
hash_init(hashtab_T *ht)
{
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
- vim_memset(ht, 0, sizeof(hashtab_T));
+ CLEAR_POINTER(ht);
ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1;
}
@@ -394,11 +394,12 @@ hash_may_resize(
}
else
oldarray = ht->ht_array;
+ CLEAR_FIELD(ht->ht_smallarray);
}
else
{
// Allocate an array.
- newarray = ALLOC_MULT(hashitem_T, newsize);
+ newarray = ALLOC_CLEAR_MULT(hashitem_T, newsize);
if (newarray == NULL)
{
// Out of memory. When there are NULL items still return OK.
@@ -411,7 +412,6 @@ hash_may_resize(
}
oldarray = ht->ht_array;
}
- vim_memset(newarray, 0, (size_t)(sizeof(hashitem_T) * newsize));
/*
* Move all the items from the old array to the new one, placing them in