diff src/if_mzsch.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 7ae2396cef62
children f0f9692d4487
line wrap: on
line diff
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -2582,7 +2582,7 @@ set_buffer_line_list(void *data, int arg
 	    MZ_GC_VAR_IN_REG(1, rest);
 	    MZ_GC_REG();
 
-	    array = (char **)alloc((new_len+1)* sizeof(char *));
+	    array = ALLOC_MULT(char *, new_len + 1);
 	    vim_memset(array, 0, (new_len+1) * sizeof(char *));
 
 	    rest = line_list;
@@ -2766,7 +2766,7 @@ insert_buffer_line_list(void *data, int 
 	MZ_GC_VAR_IN_REG(1, rest);
 	MZ_GC_REG();
 
-	array = (char **)alloc((size+1) * sizeof(char *));
+	array = ALLOC_MULT(char *, size + 1);
 	vim_memset(array, 0, (size+1) * sizeof(char *));
 
 	rest = list;
@@ -2886,7 +2886,7 @@ string_to_line(Scheme_Object *obj)
     if (memchr(scheme_str, '\n', len))
 	scheme_signal_error(_("string cannot contain newlines"));
 
-    vim_str = (char *)alloc(len + 1);
+    vim_str = alloc(len + 1);
 
     /* Create a copy of the string, with internal nulls replaced by
      * newline characters, as is the vim convention.
@@ -3213,14 +3213,14 @@ mzscheme_to_vim_impl(Scheme_Object *obj,
 	    tv->vval.v_list = list;
 	    ++list->lv_refcount;
 
-	    v = (typval_T *)alloc(sizeof(typval_T));
+	    v = ALLOC_ONE(typval_T);
 	    if (v == NULL)
 		status = FAIL;
 	    else
 	    {
 		/* add the value in advance to allow handling of self-referential
 		 * data structures */
-		typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+		typval_T    *visited_tv = ALLOC_ONE(typval_T);
 		copy_tv(tv, visited_tv);
 		scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
 
@@ -3288,7 +3288,7 @@ mzscheme_to_vim_impl(Scheme_Object *obj,
 	    status = FAIL;
 	else
 	{
-	    typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+	    typval_T    *visited_tv = ALLOC_ONE(typval_T);
 
 	    tv->v_type = VAR_DICT;
 	    tv->vval.v_dict = dict;
@@ -3353,7 +3353,7 @@ vim_funcref(void *name, int argc, Scheme
 	++list->lv_refcount;
 	for (i = 0; status == OK && i < argc; ++i)
 	{
-	    typval_T *v = (typval_T *)alloc(sizeof(typval_T));
+	    typval_T *v = ALLOC_ONE(typval_T);
 	    if (v == NULL)
 		status = FAIL;
 	    else