Mercurial > vim
comparison src/ex_cmds.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 | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
593 if (got_int) | 593 if (got_int) |
594 goto sortend; | 594 goto sortend; |
595 } | 595 } |
596 | 596 |
597 /* Allocate a buffer that can hold the longest line. */ | 597 /* Allocate a buffer that can hold the longest line. */ |
598 sortbuf1 = alloc((unsigned)maxlen + 1); | 598 sortbuf1 = alloc(maxlen + 1); |
599 if (sortbuf1 == NULL) | 599 if (sortbuf1 == NULL) |
600 goto sortend; | 600 goto sortend; |
601 sortbuf2 = alloc((unsigned)maxlen + 1); | 601 sortbuf2 = alloc(maxlen + 1); |
602 if (sortbuf2 == NULL) | 602 if (sortbuf2 == NULL) |
603 goto sortend; | 603 goto sortend; |
604 | 604 |
605 /* Sort the array of line numbers. Note: can't be interrupted! */ | 605 /* Sort the array of line numbers. Note: can't be interrupted! */ |
606 qsort((void *)nrs, count, sizeof(sorti_T), sort_compare); | 606 qsort((void *)nrs, count, sizeof(sorti_T), sort_compare); |
1144 vim_free(newcmd); | 1144 vim_free(newcmd); |
1145 return; | 1145 return; |
1146 } | 1146 } |
1147 len += (int)STRLEN(prevcmd); | 1147 len += (int)STRLEN(prevcmd); |
1148 } | 1148 } |
1149 if ((t = alloc((unsigned)len)) == NULL) | 1149 if ((t = alloc(len)) == NULL) |
1150 { | 1150 { |
1151 vim_free(newcmd); | 1151 vim_free(newcmd); |
1152 return; | 1152 return; |
1153 } | 1153 } |
1154 *t = NUL; | 1154 *t = NUL; |
1207 /* | 1207 /* |
1208 * Add quotes around the command, for shells that need them. | 1208 * Add quotes around the command, for shells that need them. |
1209 */ | 1209 */ |
1210 if (*p_shq != NUL) | 1210 if (*p_shq != NUL) |
1211 { | 1211 { |
1212 newcmd = alloc((unsigned)(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1)); | 1212 newcmd = alloc(STRLEN(prevcmd) + 2 * STRLEN(p_shq) + 1); |
1213 if (newcmd == NULL) | 1213 if (newcmd == NULL) |
1214 return; | 1214 return; |
1215 STRCPY(newcmd, p_shq); | 1215 STRCPY(newcmd, p_shq); |
1216 STRCAT(newcmd, prevcmd); | 1216 STRCAT(newcmd, prevcmd); |
1217 STRCAT(newcmd, p_shq); | 1217 STRCAT(newcmd, p_shq); |
3906 /* Set v:swapcommand for the SwapExists autocommands. */ | 3906 /* Set v:swapcommand for the SwapExists autocommands. */ |
3907 if (command != NULL) | 3907 if (command != NULL) |
3908 len = (int)STRLEN(command) + 3; | 3908 len = (int)STRLEN(command) + 3; |
3909 else | 3909 else |
3910 len = 30; | 3910 len = 30; |
3911 p = alloc((unsigned)len); | 3911 p = alloc(len); |
3912 if (p != NULL) | 3912 if (p != NULL) |
3913 { | 3913 { |
3914 if (command != NULL) | 3914 if (command != NULL) |
3915 vim_snprintf((char *)p, len, ":%s\r", command); | 3915 vim_snprintf((char *)p, len, ":%s\r", command); |
3916 else | 3916 else |
5632 * Get some space for a temporary buffer to do the | 5632 * Get some space for a temporary buffer to do the |
5633 * substitution into (and some extra space to avoid | 5633 * substitution into (and some extra space to avoid |
5634 * too many calls to alloc()/free()). | 5634 * too many calls to alloc()/free()). |
5635 */ | 5635 */ |
5636 new_start_len = needed_len + 50; | 5636 new_start_len = needed_len + 50; |
5637 if ((new_start = alloc_check(new_start_len)) == NULL) | 5637 if ((new_start = alloc(new_start_len)) == NULL) |
5638 goto outofmem; | 5638 goto outofmem; |
5639 *new_start = NUL; | 5639 *new_start = NUL; |
5640 new_end = new_start; | 5640 new_end = new_start; |
5641 } | 5641 } |
5642 else | 5642 else |
5649 len = (unsigned)STRLEN(new_start); | 5649 len = (unsigned)STRLEN(new_start); |
5650 needed_len += len; | 5650 needed_len += len; |
5651 if (needed_len > (int)new_start_len) | 5651 if (needed_len > (int)new_start_len) |
5652 { | 5652 { |
5653 new_start_len = needed_len + 50; | 5653 new_start_len = needed_len + 50; |
5654 if ((p1 = alloc_check(new_start_len)) == NULL) | 5654 if ((p1 = alloc(new_start_len)) == NULL) |
5655 { | 5655 { |
5656 vim_free(new_start); | 5656 vim_free(new_start); |
5657 goto outofmem; | 5657 goto outofmem; |
5658 } | 5658 } |
5659 mch_memmove(p1, new_start, (size_t)(len + 1)); | 5659 mch_memmove(p1, new_start, (size_t)(len + 1)); |
7318 if (ga_grow(&ga, 1) == FAIL) | 7318 if (ga_grow(&ga, 1) == FAIL) |
7319 { | 7319 { |
7320 got_int = TRUE; | 7320 got_int = TRUE; |
7321 break; | 7321 break; |
7322 } | 7322 } |
7323 s = alloc((unsigned)(p2 - p1 + STRLEN(fname) + 2)); | 7323 s = alloc(p2 - p1 + STRLEN(fname) + 2); |
7324 if (s == NULL) | 7324 if (s == NULL) |
7325 { | 7325 { |
7326 got_int = TRUE; | 7326 got_int = TRUE; |
7327 break; | 7327 break; |
7328 } | 7328 } |