patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Problem: Using "int" for alloc() often results in compiler warnings.
Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim
only works with 32 bit ints anyway.
diff --git a/src/eval.c b/src/eval.c
index 6950348..4796a25 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -5151,7 +5151,7 @@
* Copy the string into allocated memory, handling backslashed
* characters.
*/
- name = alloc((unsigned)(p - *arg + extra));
+ name = alloc(p - *arg + extra);
if (name == NULL)
return FAIL;
rettv->v_type = VAR_STRING;
@@ -5285,7 +5285,7 @@
/*
* Copy the string into allocated memory, handling '' to ' reduction.
*/
- str = alloc((unsigned)((p - *arg) - reduce));
+ str = alloc((p - *arg) - reduce);
if (str == NULL)
return FAIL;
rettv->v_type = VAR_STRING;
@@ -6782,8 +6782,8 @@
temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE);
if (temp_result != NULL && nextcmd == NULL)
{
- retval = alloc((unsigned)(STRLEN(temp_result) + (expr_start - in_start)
- + (in_end - expr_end) + 1));
+ retval = alloc(STRLEN(temp_result) + (expr_start - in_start)
+ + (in_end - expr_end) + 1);
if (retval != NULL)
{
STRCPY(retval, in_start);
@@ -8130,8 +8130,7 @@
if (!valid_varname(varname))
return;
- v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
- + STRLEN(varname)));
+ v = (dictitem_T *)alloc(sizeof(dictitem_T) + STRLEN(varname));
if (v == NULL)
return;
STRCPY(v->di_key, varname);
@@ -8993,7 +8992,7 @@
}
else
{
- winvarname = alloc((unsigned)STRLEN(varname) + 3);
+ winvarname = alloc(STRLEN(varname) + 3);
if (winvarname != NULL)
{
STRCPY(winvarname, "w:");
@@ -9056,7 +9055,7 @@
char_u *scriptname;
/* Get the script file name: replace '#' with '/', append ".vim". */
- scriptname = alloc((unsigned)(STRLEN(name) + 14));
+ scriptname = alloc(STRLEN(name) + 14);
if (scriptname == NULL)
return FALSE;
STRCPY(scriptname, "autoload/");