From a80faa8930ed5a554beeb2727762538873135e83 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 12 Apr 2020 19:37:17 +0200 Subject: patch 8.2.0559: clearing a struct is verbose Problem: Clearing a struct is verbose. Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER(). --- src/hashtab.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/hashtab.c') 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 -- cgit v1.2.3