Mercurial > vim
comparison src/ex_getln.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 |
---|---|
4152 vim_beep(BO_WILD); | 4152 vim_beep(BO_WILD); |
4153 break; | 4153 break; |
4154 } | 4154 } |
4155 } | 4155 } |
4156 | 4156 |
4157 ss = alloc((unsigned)len + 1); | 4157 ss = alloc(len + 1); |
4158 if (ss) | 4158 if (ss) |
4159 vim_strncpy(ss, xp->xp_files[0], (size_t)len); | 4159 vim_strncpy(ss, xp->xp_files[0], (size_t)len); |
4160 findex = -1; /* next p_wc gets first one */ | 4160 findex = -1; /* next p_wc gets first one */ |
4161 } | 4161 } |
4162 | 4162 |
4360 static void | 4360 static void |
4361 escape_fname(char_u **pp) | 4361 escape_fname(char_u **pp) |
4362 { | 4362 { |
4363 char_u *p; | 4363 char_u *p; |
4364 | 4364 |
4365 p = alloc((unsigned)(STRLEN(*pp) + 2)); | 4365 p = alloc(STRLEN(*pp) + 2); |
4366 if (p != NULL) | 4366 if (p != NULL) |
4367 { | 4367 { |
4368 p[0] = '\\'; | 4368 p[0] = '\\'; |
4369 STRCPY(p + 1, *pp); | 4369 STRCPY(p + 1, *pp); |
4370 vim_free(*pp); | 4370 vim_free(*pp); |
5292 if (round == 0) | 5292 if (round == 0) |
5293 { | 5293 { |
5294 if (count == 0) | 5294 if (count == 0) |
5295 return OK; | 5295 return OK; |
5296 *num_file = count; | 5296 *num_file = count; |
5297 *file = (char_u **)alloc((unsigned)(count * sizeof(char_u *))); | 5297 *file = (char_u **)alloc(count * sizeof(char_u *)); |
5298 if (*file == NULL) | 5298 if (*file == NULL) |
5299 { | 5299 { |
5300 *file = (char_u **)""; | 5300 *file = (char_u **)""; |
5301 return FAIL; | 5301 return FAIL; |
5302 } | 5302 } |
5634 pat_len = (int)STRLEN(pat); | 5634 pat_len = (int)STRLEN(pat); |
5635 ga_init2(&ga, (int)sizeof(char *), 10); | 5635 ga_init2(&ga, (int)sizeof(char *), 10); |
5636 | 5636 |
5637 for (i = 0; dirnames[i] != NULL; ++i) | 5637 for (i = 0; dirnames[i] != NULL; ++i) |
5638 { | 5638 { |
5639 s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7)); | 5639 s = alloc(STRLEN(dirnames[i]) + pat_len + 7); |
5640 if (s == NULL) | 5640 if (s == NULL) |
5641 { | 5641 { |
5642 ga_clear_strings(&ga); | 5642 ga_clear_strings(&ga); |
5643 return FAIL; | 5643 return FAIL; |
5644 } | 5644 } |
5648 } | 5648 } |
5649 | 5649 |
5650 if (flags & DIP_START) { | 5650 if (flags & DIP_START) { |
5651 for (i = 0; dirnames[i] != NULL; ++i) | 5651 for (i = 0; dirnames[i] != NULL; ++i) |
5652 { | 5652 { |
5653 s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 22)); | 5653 s = alloc(STRLEN(dirnames[i]) + pat_len + 22); |
5654 if (s == NULL) | 5654 if (s == NULL) |
5655 { | 5655 { |
5656 ga_clear_strings(&ga); | 5656 ga_clear_strings(&ga); |
5657 return FAIL; | 5657 return FAIL; |
5658 } | 5658 } |
5663 } | 5663 } |
5664 | 5664 |
5665 if (flags & DIP_OPT) { | 5665 if (flags & DIP_OPT) { |
5666 for (i = 0; dirnames[i] != NULL; ++i) | 5666 for (i = 0; dirnames[i] != NULL; ++i) |
5667 { | 5667 { |
5668 s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 20)); | 5668 s = alloc(STRLEN(dirnames[i]) + pat_len + 20); |
5669 if (s == NULL) | 5669 if (s == NULL) |
5670 { | 5670 { |
5671 ga_clear_strings(&ga); | 5671 ga_clear_strings(&ga); |
5672 return FAIL; | 5672 return FAIL; |
5673 } | 5673 } |
5726 *num_file = 0; | 5726 *num_file = 0; |
5727 *file = NULL; | 5727 *file = NULL; |
5728 pat_len = (int)STRLEN(pat); | 5728 pat_len = (int)STRLEN(pat); |
5729 ga_init2(&ga, (int)sizeof(char *), 10); | 5729 ga_init2(&ga, (int)sizeof(char *), 10); |
5730 | 5730 |
5731 s = alloc((unsigned)(pat_len + 26)); | 5731 s = alloc(pat_len + 26); |
5732 if (s == NULL) | 5732 if (s == NULL) |
5733 { | 5733 { |
5734 ga_clear_strings(&ga); | 5734 ga_clear_strings(&ga); |
5735 return FAIL; | 5735 return FAIL; |
5736 } | 5736 } |