comparison 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
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
5292 if (round == 0) 5292 if (round == 0)
5293 { 5293 {
5294 if (count == 0) 5294 if (count == 0)
5295 return OK; 5295 return OK;
5296 *num_file = count; 5296 *num_file = count;
5297 *file = (char_u **)alloc(count * sizeof(char_u *)); 5297 *file = ALLOC_MULT(char_u *, count);
5298 if (*file == NULL) 5298 if (*file == NULL)
5299 { 5299 {
5300 *file = (char_u **)""; 5300 *file = (char_u **)"";
5301 return FAIL; 5301 return FAIL;
5302 } 5302 }
5912 { 5912 {
5913 for (type = 0; type < HIST_COUNT; ++type) /* adjust the tables */ 5913 for (type = 0; type < HIST_COUNT; ++type) /* adjust the tables */
5914 { 5914 {
5915 if (newlen) 5915 if (newlen)
5916 { 5916 {
5917 temp = (histentry_T *)alloc(newlen * sizeof(histentry_T)); 5917 temp = ALLOC_MULT(histentry_T, newlen);
5918 if (temp == NULL) /* out of memory! */ 5918 if (temp == NULL) /* out of memory! */
5919 { 5919 {
5920 if (type == 0) /* first one: just keep the old length */ 5920 if (type == 0) /* first one: just keep the old length */
5921 { 5921 {
5922 newlen = hislen; 5922 newlen = hislen;
6651 if (num > len) 6651 if (num > len)
6652 len = num; 6652 len = num;
6653 if (len <= 0) 6653 if (len <= 0)
6654 viminfo_history[type] = NULL; 6654 viminfo_history[type] = NULL;
6655 else 6655 else
6656 viminfo_history[type] = (histentry_T *)lalloc( 6656 viminfo_history[type] = LALLOC_MULT(histentry_T, len);
6657 len * sizeof(histentry_T), FALSE);
6658 if (viminfo_history[type] == NULL) 6657 if (viminfo_history[type] == NULL)
6659 len = 0; 6658 len = 0;
6660 viminfo_hislen[type] = len; 6659 viminfo_hislen[type] = len;
6661 viminfo_hisidx[type] = 0; 6660 viminfo_hisidx[type] = 0;
6662 } 6661 }
6871 int i; 6870 int i;
6872 int len; 6871 int len;
6873 6872
6874 /* Make one long list with all entries. */ 6873 /* Make one long list with all entries. */
6875 max_len = hislen + viminfo_hisidx[type]; 6874 max_len = hislen + viminfo_hisidx[type];
6876 tot_hist = (histentry_T **)alloc(max_len * (int)sizeof(histentry_T *)); 6875 tot_hist = ALLOC_MULT(histentry_T *, max_len);
6877 new_hist = (histentry_T *)alloc(hislen * (int)sizeof(histentry_T)); 6876 new_hist = ALLOC_MULT(histentry_T, hislen );
6878 if (tot_hist == NULL || new_hist == NULL) 6877 if (tot_hist == NULL || new_hist == NULL)
6879 { 6878 {
6880 vim_free(tot_hist); 6879 vim_free(tot_hist);
6881 vim_free(new_hist); 6880 vim_free(new_hist);
6882 return; 6881 return;