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/undo.c b/src/undo.c
index 6547ee6..cf3f866 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -468,7 +468,7 @@
* Make a new header entry. Do this first so that we don't mess
* up the undo info when out of memory.
*/
- uhp = (u_header_T *)U_ALLOC_LINE(sizeof(u_header_T));
+ uhp = U_ALLOC_LINE(sizeof(u_header_T));
if (uhp == NULL)
goto nomem;
#ifdef U_DEBUG
@@ -659,7 +659,7 @@
/*
* add lines in front of entry list
*/
- uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T));
+ uep = U_ALLOC_LINE(sizeof(u_entry_T));
if (uep == NULL)
goto nomem;
vim_memset(uep, 0, sizeof(u_entry_T));
@@ -685,8 +685,7 @@
if (size > 0)
{
- if ((uep->ue_array = (undoline_T *)U_ALLOC_LINE(
- sizeof(undoline_T) * size)) == NULL)
+ if ((uep->ue_array = U_ALLOC_LINE(sizeof(undoline_T) * size)) == NULL)
{
u_freeentry(uep, 0L);
goto nomem;
@@ -1286,7 +1285,7 @@
int c;
int error;
- uhp = (u_header_T *)U_ALLOC_LINE(sizeof(u_header_T));
+ uhp = U_ALLOC_LINE(sizeof(u_header_T));
if (uhp == NULL)
return NULL;
vim_memset(uhp, 0, sizeof(u_header_T));
@@ -1397,7 +1396,7 @@
char_u *line;
int line_len;
- uep = (u_entry_T *)U_ALLOC_LINE(sizeof(u_entry_T));
+ uep = U_ALLOC_LINE(sizeof(u_entry_T));
if (uep == NULL)
return NULL;
vim_memset(uep, 0, sizeof(u_entry_T));
@@ -1411,7 +1410,7 @@
if (uep->ue_size > 0)
{
if (uep->ue_size < LONG_MAX / (int)sizeof(char_u *))
- array = (undoline_T *)U_ALLOC_LINE(sizeof(undoline_T) * uep->ue_size);
+ array = U_ALLOC_LINE(sizeof(undoline_T) * uep->ue_size);
if (array == NULL)
{
*error = TRUE;
@@ -1981,8 +1980,7 @@
if (num_head > 0)
{
if (num_head < LONG_MAX / (long)sizeof(u_header_T *))
- uhp_table = (u_header_T **)U_ALLOC_LINE(
- num_head * sizeof(u_header_T *));
+ uhp_table = U_ALLOC_LINE(num_head * sizeof(u_header_T *));
if (uhp_table == NULL)
goto error;
}
@@ -2013,7 +2011,7 @@
}
#ifdef U_DEBUG
- uhp_table_used = (int *)alloc_clear(sizeof(int) * num_head + 1);
+ uhp_table_used = alloc_clear(sizeof(int) * num_head + 1);
# define SET_FLAG(j) ++uhp_table_used[j]
#else
# define SET_FLAG(j)
@@ -2712,8 +2710,7 @@
/* delete the lines between top and bot and save them in newarray */
if (oldsize > 0)
{
- if ((newarray = (undoline_T *)U_ALLOC_LINE(
- sizeof(undoline_T) * oldsize)) == NULL)
+ if ((newarray = U_ALLOC_LINE(sizeof(undoline_T) * oldsize)) == NULL)
{
do_outofmem_msg((long_u)(sizeof(undoline_T) * oldsize));
/*