Mercurial > vim
diff src/ex_getln.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 | fc58fee685e2 |
children | da2bb80cd838 |
line wrap: on
line diff
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -5294,7 +5294,7 @@ ExpandGeneric( if (count == 0) return OK; *num_file = count; - *file = (char_u **)alloc(count * sizeof(char_u *)); + *file = ALLOC_MULT(char_u *, count); if (*file == NULL) { *file = (char_u **)""; @@ -5914,7 +5914,7 @@ init_history(void) { if (newlen) { - temp = (histentry_T *)alloc(newlen * sizeof(histentry_T)); + temp = ALLOC_MULT(histentry_T, newlen); if (temp == NULL) /* out of memory! */ { if (type == 0) /* first one: just keep the old length */ @@ -6653,8 +6653,7 @@ prepare_viminfo_history(int asklen, int if (len <= 0) viminfo_history[type] = NULL; else - viminfo_history[type] = (histentry_T *)lalloc( - len * sizeof(histentry_T), FALSE); + viminfo_history[type] = LALLOC_MULT(histentry_T, len); if (viminfo_history[type] == NULL) len = 0; viminfo_hislen[type] = len; @@ -6873,8 +6872,8 @@ merge_history(int type) /* Make one long list with all entries. */ max_len = hislen + viminfo_hisidx[type]; - tot_hist = (histentry_T **)alloc(max_len * (int)sizeof(histentry_T *)); - new_hist = (histentry_T *)alloc(hislen * (int)sizeof(histentry_T)); + tot_hist = ALLOC_MULT(histentry_T *, max_len); + new_hist = ALLOC_MULT(histentry_T, hislen ); if (tot_hist == NULL || new_hist == NULL) { vim_free(tot_hist);