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.
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 80f1855..c6d22e5 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -5294,7 +5294,7 @@
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 @@
{
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 @@
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 @@
/* 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);