diff src/ex_cmds2.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 fc58fee685e2
children a836d122231a
line wrap: on
line diff
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -293,7 +293,7 @@ free_timer(timer_T *timer)
     timer_T *
 create_timer(long msec, int repeat)
 {
-    timer_T	*timer = (timer_T *)alloc_clear(sizeof(timer_T));
+    timer_T	*timer = ALLOC_CLEAR_ONE(timer_T);
     long	prev_id = last_timer_id;
 
     if (timer == NULL)
@@ -444,7 +444,7 @@ check_due_timer(void)
 	    bevalexpr_due_set = FALSE;
 	    if (balloonEval == NULL)
 	    {
-		balloonEval = (BalloonEval *)alloc_clear(sizeof(BalloonEval));
+		balloonEval = ALLOC_CLEAR_ONE(BalloonEval);
 		balloonEvalForTerm = TRUE;
 	    }
 	    if (balloonEval != NULL)
@@ -1312,7 +1312,7 @@ check_changed_any(
     if (bufcount == 0)
 	return FALSE;
 
-    bufnrs = (int *)alloc(sizeof(int) * bufcount);
+    bufnrs = ALLOC_MULT(int, bufcount);
     if (bufnrs == NULL)
 	return FALSE;
 
@@ -1783,7 +1783,7 @@ ex_args(exarg_T *eap)
 	 */
 	if (ARGCOUNT > 0)
 	{
-	    char_u **items = (char_u **)alloc(sizeof(char_u *) * ARGCOUNT);
+	    char_u **items = ALLOC_MULT(char_u *, ARGCOUNT);
 
 	    if (items != NULL)
 	    {
@@ -2994,7 +2994,7 @@ ex_packadd(exarg_T *eap)
 	    continue;
 
 	len = (int)STRLEN(plugpat) + (int)STRLEN(eap->arg) + 5;
-	pat = (char *)alloc(len);
+	pat = alloc(len);
 	if (pat == NULL)
 	    return;
 	vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg);