Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
2580 MZ_GC_DECL_REG(2); | 2580 MZ_GC_DECL_REG(2); |
2581 MZ_GC_VAR_IN_REG(0, line); | 2581 MZ_GC_VAR_IN_REG(0, line); |
2582 MZ_GC_VAR_IN_REG(1, rest); | 2582 MZ_GC_VAR_IN_REG(1, rest); |
2583 MZ_GC_REG(); | 2583 MZ_GC_REG(); |
2584 | 2584 |
2585 array = (char **)alloc((new_len+1)* sizeof(char *)); | 2585 array = ALLOC_MULT(char *, new_len + 1); |
2586 vim_memset(array, 0, (new_len+1) * sizeof(char *)); | 2586 vim_memset(array, 0, (new_len+1) * sizeof(char *)); |
2587 | 2587 |
2588 rest = line_list; | 2588 rest = line_list; |
2589 for (i = 0; i < new_len; ++i) | 2589 for (i = 0; i < new_len; ++i) |
2590 { | 2590 { |
2764 MZ_GC_DECL_REG(2); | 2764 MZ_GC_DECL_REG(2); |
2765 MZ_GC_VAR_IN_REG(0, line); | 2765 MZ_GC_VAR_IN_REG(0, line); |
2766 MZ_GC_VAR_IN_REG(1, rest); | 2766 MZ_GC_VAR_IN_REG(1, rest); |
2767 MZ_GC_REG(); | 2767 MZ_GC_REG(); |
2768 | 2768 |
2769 array = (char **)alloc((size+1) * sizeof(char *)); | 2769 array = ALLOC_MULT(char *, size + 1); |
2770 vim_memset(array, 0, (size+1) * sizeof(char *)); | 2770 vim_memset(array, 0, (size+1) * sizeof(char *)); |
2771 | 2771 |
2772 rest = list; | 2772 rest = list; |
2773 for (i = 0; i < size; ++i) | 2773 for (i = 0; i < size; ++i) |
2774 { | 2774 { |
2884 * a single line. | 2884 * a single line. |
2885 */ | 2885 */ |
2886 if (memchr(scheme_str, '\n', len)) | 2886 if (memchr(scheme_str, '\n', len)) |
2887 scheme_signal_error(_("string cannot contain newlines")); | 2887 scheme_signal_error(_("string cannot contain newlines")); |
2888 | 2888 |
2889 vim_str = (char *)alloc(len + 1); | 2889 vim_str = alloc(len + 1); |
2890 | 2890 |
2891 /* Create a copy of the string, with internal nulls replaced by | 2891 /* Create a copy of the string, with internal nulls replaced by |
2892 * newline characters, as is the vim convention. | 2892 * newline characters, as is the vim convention. |
2893 */ | 2893 */ |
2894 for (i = 0; i < len; ++i) | 2894 for (i = 0; i < len; ++i) |
3211 | 3211 |
3212 tv->v_type = VAR_LIST; | 3212 tv->v_type = VAR_LIST; |
3213 tv->vval.v_list = list; | 3213 tv->vval.v_list = list; |
3214 ++list->lv_refcount; | 3214 ++list->lv_refcount; |
3215 | 3215 |
3216 v = (typval_T *)alloc(sizeof(typval_T)); | 3216 v = ALLOC_ONE(typval_T); |
3217 if (v == NULL) | 3217 if (v == NULL) |
3218 status = FAIL; | 3218 status = FAIL; |
3219 else | 3219 else |
3220 { | 3220 { |
3221 /* add the value in advance to allow handling of self-referential | 3221 /* add the value in advance to allow handling of self-referential |
3222 * data structures */ | 3222 * data structures */ |
3223 typval_T *visited_tv = (typval_T *)alloc(sizeof(typval_T)); | 3223 typval_T *visited_tv = ALLOC_ONE(typval_T); |
3224 copy_tv(tv, visited_tv); | 3224 copy_tv(tv, visited_tv); |
3225 scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); | 3225 scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); |
3226 | 3226 |
3227 if (SCHEME_VECTORP(obj)) | 3227 if (SCHEME_VECTORP(obj)) |
3228 { | 3228 { |
3286 dict = dict_alloc(); | 3286 dict = dict_alloc(); |
3287 if (dict == NULL) | 3287 if (dict == NULL) |
3288 status = FAIL; | 3288 status = FAIL; |
3289 else | 3289 else |
3290 { | 3290 { |
3291 typval_T *visited_tv = (typval_T *)alloc(sizeof(typval_T)); | 3291 typval_T *visited_tv = ALLOC_ONE(typval_T); |
3292 | 3292 |
3293 tv->v_type = VAR_DICT; | 3293 tv->v_type = VAR_DICT; |
3294 tv->vval.v_dict = dict; | 3294 tv->vval.v_dict = dict; |
3295 ++dict->dv_refcount; | 3295 ++dict->dv_refcount; |
3296 | 3296 |
3351 args.v_type = VAR_LIST; | 3351 args.v_type = VAR_LIST; |
3352 args.vval.v_list = list; | 3352 args.vval.v_list = list; |
3353 ++list->lv_refcount; | 3353 ++list->lv_refcount; |
3354 for (i = 0; status == OK && i < argc; ++i) | 3354 for (i = 0; status == OK && i < argc; ++i) |
3355 { | 3355 { |
3356 typval_T *v = (typval_T *)alloc(sizeof(typval_T)); | 3356 typval_T *v = ALLOC_ONE(typval_T); |
3357 if (v == NULL) | 3357 if (v == NULL) |
3358 status = FAIL; | 3358 status = FAIL; |
3359 else | 3359 else |
3360 { | 3360 { |
3361 status = mzscheme_to_vim(argv[i], v); | 3361 status = mzscheme_to_vim(argv[i], v); |