Mercurial > vim
comparison src/eval.c @ 16764:ef00b6bc186b v8.1.1384
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
commit https://github.com/vim/vim/commit/964b3746b9c81e65887e2ac9a335f181db2bb592
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 18:54:09 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 19:00:07 +0200 |
parents | 77bcb5055fec |
children | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
5149 | 5149 |
5150 /* | 5150 /* |
5151 * Copy the string into allocated memory, handling backslashed | 5151 * Copy the string into allocated memory, handling backslashed |
5152 * characters. | 5152 * characters. |
5153 */ | 5153 */ |
5154 name = alloc((unsigned)(p - *arg + extra)); | 5154 name = alloc(p - *arg + extra); |
5155 if (name == NULL) | 5155 if (name == NULL) |
5156 return FAIL; | 5156 return FAIL; |
5157 rettv->v_type = VAR_STRING; | 5157 rettv->v_type = VAR_STRING; |
5158 rettv->vval.v_string = name; | 5158 rettv->vval.v_string = name; |
5159 | 5159 |
5283 } | 5283 } |
5284 | 5284 |
5285 /* | 5285 /* |
5286 * Copy the string into allocated memory, handling '' to ' reduction. | 5286 * Copy the string into allocated memory, handling '' to ' reduction. |
5287 */ | 5287 */ |
5288 str = alloc((unsigned)((p - *arg) - reduce)); | 5288 str = alloc((p - *arg) - reduce); |
5289 if (str == NULL) | 5289 if (str == NULL) |
5290 return FAIL; | 5290 return FAIL; |
5291 rettv->v_type = VAR_STRING; | 5291 rettv->v_type = VAR_STRING; |
5292 rettv->vval.v_string = str; | 5292 rettv->vval.v_string = str; |
5293 | 5293 |
6780 *in_end = NUL; | 6780 *in_end = NUL; |
6781 | 6781 |
6782 temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE); | 6782 temp_result = eval_to_string(expr_start + 1, &nextcmd, FALSE); |
6783 if (temp_result != NULL && nextcmd == NULL) | 6783 if (temp_result != NULL && nextcmd == NULL) |
6784 { | 6784 { |
6785 retval = alloc((unsigned)(STRLEN(temp_result) + (expr_start - in_start) | 6785 retval = alloc(STRLEN(temp_result) + (expr_start - in_start) |
6786 + (in_end - expr_end) + 1)); | 6786 + (in_end - expr_end) + 1); |
6787 if (retval != NULL) | 6787 if (retval != NULL) |
6788 { | 6788 { |
6789 STRCPY(retval, in_start); | 6789 STRCPY(retval, in_start); |
6790 STRCAT(retval, temp_result); | 6790 STRCAT(retval, temp_result); |
6791 STRCAT(retval, expr_end + 1); | 6791 STRCAT(retval, expr_end + 1); |
8128 | 8128 |
8129 // Make sure the variable name is valid. | 8129 // Make sure the variable name is valid. |
8130 if (!valid_varname(varname)) | 8130 if (!valid_varname(varname)) |
8131 return; | 8131 return; |
8132 | 8132 |
8133 v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T) | 8133 v = (dictitem_T *)alloc(sizeof(dictitem_T) + STRLEN(varname)); |
8134 + STRLEN(varname))); | |
8135 if (v == NULL) | 8134 if (v == NULL) |
8136 return; | 8135 return; |
8137 STRCPY(v->di_key, varname); | 8136 STRCPY(v->di_key, varname); |
8138 if (hash_add(ht, DI2HIKEY(v)) == FAIL) | 8137 if (hash_add(ht, DI2HIKEY(v)) == FAIL) |
8139 { | 8138 { |
8991 if (!error && strval != NULL) | 8990 if (!error && strval != NULL) |
8992 set_option_value(varname, numval, strval, OPT_LOCAL); | 8991 set_option_value(varname, numval, strval, OPT_LOCAL); |
8993 } | 8992 } |
8994 else | 8993 else |
8995 { | 8994 { |
8996 winvarname = alloc((unsigned)STRLEN(varname) + 3); | 8995 winvarname = alloc(STRLEN(varname) + 3); |
8997 if (winvarname != NULL) | 8996 if (winvarname != NULL) |
8998 { | 8997 { |
8999 STRCPY(winvarname, "w:"); | 8998 STRCPY(winvarname, "w:"); |
9000 STRCPY(winvarname + 2, varname); | 8999 STRCPY(winvarname + 2, varname); |
9001 set_var(winvarname, varp, TRUE); | 9000 set_var(winvarname, varp, TRUE); |
9054 { | 9053 { |
9055 char_u *p; | 9054 char_u *p; |
9056 char_u *scriptname; | 9055 char_u *scriptname; |
9057 | 9056 |
9058 /* Get the script file name: replace '#' with '/', append ".vim". */ | 9057 /* Get the script file name: replace '#' with '/', append ".vim". */ |
9059 scriptname = alloc((unsigned)(STRLEN(name) + 14)); | 9058 scriptname = alloc(STRLEN(name) + 14); |
9060 if (scriptname == NULL) | 9059 if (scriptname == NULL) |
9061 return FALSE; | 9060 return FALSE; |
9062 STRCPY(scriptname, "autoload/"); | 9061 STRCPY(scriptname, "autoload/"); |
9063 STRCAT(scriptname, name); | 9062 STRCAT(scriptname, name); |
9064 *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; | 9063 *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL; |