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/getchar.c b/src/getchar.c
index 9eacdc9..02535ce 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -258,7 +258,7 @@
len = MINIMAL_SIZE;
else
len = slen;
- p = (buffblock_T *)alloc(sizeof(buffblock_T) + len);
+ p = alloc(sizeof(buffblock_T) + len);
if (p == NULL)
return; /* no space, just forget it */
buf->bh_space = (int)(len - slen);
@@ -3730,7 +3730,7 @@
/*
* Get here when adding a new entry to the maphash[] list or abbrlist.
*/
- mp = (mapblock_T *)alloc(sizeof(mapblock_T));
+ mp = ALLOC_ONE(mapblock_T);
if (mp == NULL)
{
retval = 4; /* no mem */
@@ -4374,7 +4374,7 @@
if (round == 1)
{
- *file = (char_u **)alloc(count * sizeof(char_u *));
+ *file = ALLOC_MULT(char_u *, count);
if (*file == NULL)
return FAIL;
}