comparison src/getchar.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 695d9ef00b03
children 998603a243d7
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
256 { 256 {
257 if (slen < MINIMAL_SIZE) 257 if (slen < MINIMAL_SIZE)
258 len = MINIMAL_SIZE; 258 len = MINIMAL_SIZE;
259 else 259 else
260 len = slen; 260 len = slen;
261 p = (buffblock_T *)alloc(sizeof(buffblock_T) + len); 261 p = alloc(sizeof(buffblock_T) + len);
262 if (p == NULL) 262 if (p == NULL)
263 return; /* no space, just forget it */ 263 return; /* no space, just forget it */
264 buf->bh_space = (int)(len - slen); 264 buf->bh_space = (int)(len - slen);
265 vim_strncpy(p->b_str, s, (size_t)slen); 265 vim_strncpy(p->b_str, s, (size_t)slen);
266 266
3728 goto theend; 3728 goto theend;
3729 3729
3730 /* 3730 /*
3731 * Get here when adding a new entry to the maphash[] list or abbrlist. 3731 * Get here when adding a new entry to the maphash[] list or abbrlist.
3732 */ 3732 */
3733 mp = (mapblock_T *)alloc(sizeof(mapblock_T)); 3733 mp = ALLOC_ONE(mapblock_T);
3734 if (mp == NULL) 3734 if (mp == NULL)
3735 { 3735 {
3736 retval = 4; /* no mem */ 3736 retval = 4; /* no mem */
3737 goto theend; 3737 goto theend;
3738 } 3738 }
4372 if (count == 0) /* no match found */ 4372 if (count == 0) /* no match found */
4373 break; /* for (round) */ 4373 break; /* for (round) */
4374 4374
4375 if (round == 1) 4375 if (round == 1)
4376 { 4376 {
4377 *file = (char_u **)alloc(count * sizeof(char_u *)); 4377 *file = ALLOC_MULT(char_u *, count);
4378 if (*file == NULL) 4378 if (*file == NULL)
4379 return FAIL; 4379 return FAIL;
4380 } 4380 }
4381 } /* for (round) */ 4381 } /* for (round) */
4382 4382