Mercurial > vim
changeset 21915:2559dc02bd64 v8.2.1507
patch 8.2.1507: using malloc() directly
Commit: https://github.com/vim/vim/commit/51b6eb47b3c41b01a5559b099e65354c8897093e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 22 15:19:18 2020 +0200
patch 8.2.1507: using malloc() directly
Problem: Using malloc() directly.
Solution: Use ALLOC_ONE(). Remove superfluous typecast. (Hussam al-Homsi,
closes #6768)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Aug 2020 15:30:04 +0200 |
parents | 9a034db1bae7 |
children | 153acbd05e5d |
files | src/eval.c src/memline.c src/version.c src/vimrun.c |
diffstat | 4 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -4352,7 +4352,8 @@ set_ref_in_item( } else { - ht_stack_T *newitem = (ht_stack_T*)malloc(sizeof(ht_stack_T)); + ht_stack_T *newitem = ALLOC_ONE(ht_stack_T); + if (newitem == NULL) abort = TRUE; else @@ -4378,8 +4379,8 @@ set_ref_in_item( } else { - list_stack_T *newitem = (list_stack_T*)malloc( - sizeof(list_stack_T)); + list_stack_T *newitem = ALLOC_ONE(list_stack_T); + if (newitem == NULL) abort = TRUE; else
--- a/src/memline.c +++ b/src/memline.c @@ -5448,8 +5448,7 @@ ml_updatechunk( chunksize_T *t_chunksize = buf->b_ml.ml_chunksize; buf->b_ml.ml_numchunks = buf->b_ml.ml_numchunks * 3 / 2; - buf->b_ml.ml_chunksize = (chunksize_T *) - vim_realloc(buf->b_ml.ml_chunksize, + buf->b_ml.ml_chunksize = vim_realloc(buf->b_ml.ml_chunksize, sizeof(chunksize_T) * buf->b_ml.ml_numchunks); if (buf->b_ml.ml_chunksize == NULL) {