comparison src/hashtab.c @ 16825:ce04ebdf26b8 v8.1.1414

patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts commit https://github.com/vim/vim/commit/c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 28 23:08:19 2019 +0200 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts Problem: Alloc() returning "char_u *" causes a lot of type casts. Solution: Have it return "void *". (Mike Williams) Define ALLOC_ONE() to check the simple allocations.
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 May 2019 23:15:10 +0200
parents ef00b6bc186b
children 34966be2e856
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
49 hashtab_T * 49 hashtab_T *
50 hash_create(void) 50 hash_create(void)
51 { 51 {
52 hashtab_T *ht; 52 hashtab_T *ht;
53 53
54 ht = (hashtab_T *)alloc(sizeof(hashtab_T)); 54 ht = ALLOC_ONE(hashtab_T);
55 if (ht != NULL) 55 if (ht != NULL)
56 hash_init(ht); 56 hash_init(ht);
57 return ht; 57 return ht;
58 } 58 }
59 #endif 59 #endif
398 oldarray = ht->ht_array; 398 oldarray = ht->ht_array;
399 } 399 }
400 else 400 else
401 { 401 {
402 /* Allocate an array. */ 402 /* Allocate an array. */
403 newarray = (hashitem_T *)alloc(sizeof(hashitem_T) * newsize); 403 newarray = ALLOC_MULT(hashitem_T, newsize);
404 if (newarray == NULL) 404 if (newarray == NULL)
405 { 405 {
406 /* Out of memory. When there are NULL items still return OK. 406 /* Out of memory. When there are NULL items still return OK.
407 * Otherwise set ht_error, because lookup may result in a hang if 407 * Otherwise set ht_error, because lookup may result in a hang if
408 * we add another item. */ 408 * we add another item. */