Mercurial > vim
comparison src/evalfunc.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 | 069ee8dc8c8d |
children | 5cebaecad422 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
4463 arg_idx = 0; | 4463 arg_idx = 0; |
4464 } | 4464 } |
4465 } | 4465 } |
4466 if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL || is_funcref) | 4466 if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL || is_funcref) |
4467 { | 4467 { |
4468 partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T)); | 4468 partial_T *pt = ALLOC_CLEAR_ONE(partial_T); |
4469 | 4469 |
4470 /* result is a VAR_PARTIAL */ | 4470 /* result is a VAR_PARTIAL */ |
4471 if (pt == NULL) | 4471 if (pt == NULL) |
4472 vim_free(name); | 4472 vim_free(name); |
4473 else | 4473 else |
4482 if (arg_pt != NULL) | 4482 if (arg_pt != NULL) |
4483 arg_len = arg_pt->pt_argc; | 4483 arg_len = arg_pt->pt_argc; |
4484 if (list != NULL) | 4484 if (list != NULL) |
4485 lv_len = list->lv_len; | 4485 lv_len = list->lv_len; |
4486 pt->pt_argc = arg_len + lv_len; | 4486 pt->pt_argc = arg_len + lv_len; |
4487 pt->pt_argv = (typval_T *)alloc( | 4487 pt->pt_argv = ALLOC_MULT(typval_T, pt->pt_argc); |
4488 sizeof(typval_T) * pt->pt_argc); | |
4489 if (pt->pt_argv == NULL) | 4488 if (pt->pt_argv == NULL) |
4490 { | 4489 { |
4491 vim_free(pt); | 4490 vim_free(pt); |
4492 vim_free(name); | 4491 vim_free(name); |
4493 goto theend; | 4492 goto theend; |
9613 { | 9612 { |
9614 long grow50pc = (prevsize * 3) / 2; | 9613 long grow50pc = (prevsize * 3) / 2; |
9615 long growmin = (long)((p - start) * 2 + prevlen); | 9614 long growmin = (long)((p - start) * 2 + prevlen); |
9616 prevsize = grow50pc > growmin ? grow50pc : growmin; | 9615 prevsize = grow50pc > growmin ? grow50pc : growmin; |
9617 } | 9616 } |
9618 newprev = prev == NULL ? alloc(prevsize) | 9617 newprev = vim_realloc(prev, prevsize); |
9619 : vim_realloc(prev, prevsize); | |
9620 if (newprev == NULL) | 9618 if (newprev == NULL) |
9621 { | 9619 { |
9622 do_outofmem_msg((long_u)prevsize); | 9620 do_outofmem_msg((long_u)prevsize); |
9623 failed = TRUE; | 9621 failed = TRUE; |
9624 break; | 9622 break; |
11786 /* If the list is NULL handle like an empty list. */ | 11784 /* If the list is NULL handle like an empty list. */ |
11787 len = ll == NULL ? 0 : ll->lv_len; | 11785 len = ll == NULL ? 0 : ll->lv_len; |
11788 | 11786 |
11789 /* First half: use for pointers to result lines; second half: use for | 11787 /* First half: use for pointers to result lines; second half: use for |
11790 * pointers to allocated copies. */ | 11788 * pointers to allocated copies. */ |
11791 lstval = (char_u **)alloc(sizeof(char_u *) * ((len + 1) * 2)); | 11789 lstval = ALLOC_MULT(char_u *, (len + 1) * 2); |
11792 if (lstval == NULL) | 11790 if (lstval == NULL) |
11793 return; | 11791 return; |
11794 curval = lstval; | 11792 curval = lstval; |
11795 allocval = lstval + len + 2; | 11793 allocval = lstval + len + 2; |
11796 curallocval = allocval; | 11794 curallocval = allocval; |
12672 info.item_compare_selfdict = argvars[2].vval.v_dict; | 12670 info.item_compare_selfdict = argvars[2].vval.v_dict; |
12673 } | 12671 } |
12674 } | 12672 } |
12675 | 12673 |
12676 /* Make an array with each entry pointing to an item in the List. */ | 12674 /* Make an array with each entry pointing to an item in the List. */ |
12677 ptrs = (sortItem_T *)alloc(len * sizeof(sortItem_T)); | 12675 ptrs = ALLOC_MULT(sortItem_T, len); |
12678 if (ptrs == NULL) | 12676 if (ptrs == NULL) |
12679 goto theend; | 12677 goto theend; |
12680 | 12678 |
12681 i = 0; | 12679 i = 0; |
12682 if (sort) | 12680 if (sort) |