From c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 28 May 2019 23:08:19 +0200 Subject: 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. --- src/if_mzsch.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/if_mzsch.c') diff --git a/src/if_mzsch.c b/src/if_mzsch.c index f648e74076..04a444e23a 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -2582,7 +2582,7 @@ set_buffer_line_list(void *data, int argc, Scheme_Object **argv) 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 argc, Scheme_Object **argv) 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, typval_T *tv, int depth, 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, typval_T *tv, int depth, 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_Object **argv) ++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 -- cgit v1.2.3