Mercurial > vim
comparison src/ex_docmd.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 | b52ea9c5f1db |
children | 491c01280a5d |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
5092 */ | 5092 */ |
5093 len = (int)STRLEN(repl); | 5093 len = (int)STRLEN(repl); |
5094 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | 5094 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; |
5095 if (eap->nextcmd != NULL) | 5095 if (eap->nextcmd != NULL) |
5096 i += (int)STRLEN(eap->nextcmd);/* add space for next command */ | 5096 i += (int)STRLEN(eap->nextcmd);/* add space for next command */ |
5097 if ((new_cmdline = alloc((unsigned)i)) == NULL) | 5097 if ((new_cmdline = alloc(i)) == NULL) |
5098 return NULL; /* out of memory! */ | 5098 return NULL; /* out of memory! */ |
5099 | 5099 |
5100 /* | 5100 /* |
5101 * Copy the stuff before the expanded part. | 5101 * Copy the stuff before the expanded part. |
5102 * Copy the expanded stuff. | 5102 * Copy the expanded stuff. |
6545 * Create a new argument list and use it for the current window. | 6545 * Create a new argument list and use it for the current window. |
6546 */ | 6546 */ |
6547 void | 6547 void |
6548 alist_new(void) | 6548 alist_new(void) |
6549 { | 6549 { |
6550 curwin->w_alist = (alist_T *)alloc((unsigned)sizeof(alist_T)); | 6550 curwin->w_alist = (alist_T *)alloc(sizeof(alist_T)); |
6551 if (curwin->w_alist == NULL) | 6551 if (curwin->w_alist == NULL) |
6552 { | 6552 { |
6553 curwin->w_alist = &global_alist; | 6553 curwin->w_alist = &global_alist; |
6554 ++global_alist.al_refcount; | 6554 ++global_alist.al_refcount; |
6555 } | 6555 } |
6579 | 6579 |
6580 /* Don't use 'suffixes' here. This should work like the shell did the | 6580 /* Don't use 'suffixes' here. This should work like the shell did the |
6581 * expansion. Also, the vimrc file isn't read yet, thus the user | 6581 * expansion. Also, the vimrc file isn't read yet, thus the user |
6582 * can't set the options. */ | 6582 * can't set the options. */ |
6583 p_su = empty_option; | 6583 p_su = empty_option; |
6584 old_arg_files = (char_u **)alloc((unsigned)(sizeof(char_u *) * GARGCOUNT)); | 6584 old_arg_files = (char_u **)alloc(sizeof(char_u *) * GARGCOUNT); |
6585 if (old_arg_files != NULL) | 6585 if (old_arg_files != NULL) |
6586 { | 6586 { |
6587 for (i = 0; i < GARGCOUNT; ++i) | 6587 for (i = 0; i < GARGCOUNT; ++i) |
6588 old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname); | 6588 old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname); |
6589 old_arg_count = GARGCOUNT; | 6589 old_arg_count = GARGCOUNT; |
8837 ) | 8837 ) |
8838 len += 2; | 8838 len += 2; |
8839 } | 8839 } |
8840 if (len > 0) | 8840 if (len > 0) |
8841 { | 8841 { |
8842 arg = alloc((unsigned)(STRLEN(eap->arg) + len + 1)); | 8842 arg = alloc(STRLEN(eap->arg) + len + 1); |
8843 if (arg != NULL) | 8843 if (arg != NULL) |
8844 { | 8844 { |
8845 len = 0; | 8845 len = 0; |
8846 for (p = eap->arg; *p != NUL; ++p) | 8846 for (p = eap->arg; *p != NUL; ++p) |
8847 { | 8847 { |
9626 retval[len] = NUL; | 9626 retval[len] = NUL; |
9627 break; | 9627 break; |
9628 } | 9628 } |
9629 | 9629 |
9630 /* allocate memory */ | 9630 /* allocate memory */ |
9631 retval = alloc((unsigned)len + 1); | 9631 retval = alloc(len + 1); |
9632 if (retval == NULL) | 9632 if (retval == NULL) |
9633 break; | 9633 break; |
9634 } | 9634 } |
9635 | 9635 |
9636 return retval; | 9636 return retval; |
10620 * ":" path separator -> "=-" | 10620 * ":" path separator -> "=-" |
10621 */ | 10621 */ |
10622 for (p = sname; *p; ++p) | 10622 for (p = sname; *p; ++p) |
10623 if (*p == '=' || vim_ispathsep(*p)) | 10623 if (*p == '=' || vim_ispathsep(*p)) |
10624 ++len; | 10624 ++len; |
10625 retval = alloc((unsigned)(STRLEN(sname) + len + STRLEN(p_vdir) + 9)); | 10625 retval = alloc(STRLEN(sname) + len + STRLEN(p_vdir) + 9); |
10626 if (retval != NULL) | 10626 if (retval != NULL) |
10627 { | 10627 { |
10628 STRCPY(retval, p_vdir); | 10628 STRCPY(retval, p_vdir); |
10629 add_pathsep(retval); | 10629 add_pathsep(retval); |
10630 s = retval + STRLEN(retval); | 10630 s = retval + STRLEN(retval); |