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/if_py_both.h b/src/if_py_both.h
index bc33a80..5362d45 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -3138,8 +3138,7 @@
pt->pt_argc = self->argc;
if (exported)
{
- pt->pt_argv = (typval_T *)alloc_clear(
- sizeof(typval_T) * self->argc);
+ pt->pt_argv = ALLOC_CLEAR_MULT(typval_T, self->argc);
for (i = 0; i < pt->pt_argc; ++i)
copy_tv(&self->argv[i], &pt->pt_argv[i]);
}
@@ -4262,7 +4261,7 @@
/* Create a copy of the string, with internal nulls replaced by
* newline characters, as is the vim convention.
*/
- save = (char *)alloc(len+1);
+ save = alloc(len+1);
if (save == NULL)
{
PyErr_NoMemory();
@@ -6243,7 +6242,8 @@
FunctionObject *func = (FunctionObject *) obj;
if (func->self != NULL || func->argv != NULL)
{
- partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T));
+ partial_T *pt = ALLOC_CLEAR_ONE(partial_T);
+
set_partial(func, pt, TRUE);
tv->vval.v_partial = pt;
tv->v_type = VAR_PARTIAL;