Mercurial > vim
comparison src/misc1.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 | fc58fee685e2 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
2178 char_u *pnew; | 2178 char_u *pnew; |
2179 | 2179 |
2180 pend1 = remove_tail(p, pend, (char_u *)"MacOS"); | 2180 pend1 = remove_tail(p, pend, (char_u *)"MacOS"); |
2181 if (pend1 != pend) | 2181 if (pend1 != pend) |
2182 { | 2182 { |
2183 pnew = alloc((unsigned)(pend1 - p) + 15); | 2183 pnew = alloc(pend1 - p + 15); |
2184 if (pnew != NULL) | 2184 if (pnew != NULL) |
2185 { | 2185 { |
2186 STRNCPY(pnew, p, (pend1 - p)); | 2186 STRNCPY(pnew, p, (pend1 - p)); |
2187 STRCPY(pnew + (pend1 - p), "Resources/vim"); | 2187 STRCPY(pnew + (pend1 - p), "Resources/vim"); |
2188 p = pnew; | 2188 p = pnew; |
2339 | 2339 |
2340 /* | 2340 /* |
2341 * Putenv does not copy the string, it has to remain | 2341 * Putenv does not copy the string, it has to remain |
2342 * valid. The allocated memory will never be freed. | 2342 * valid. The allocated memory will never be freed. |
2343 */ | 2343 */ |
2344 envbuf = alloc((unsigned)(STRLEN(name) + STRLEN(val) + 2)); | 2344 envbuf = alloc(STRLEN(name) + STRLEN(val) + 2); |
2345 if (envbuf != NULL) | 2345 if (envbuf != NULL) |
2346 { | 2346 { |
2347 sprintf((char *)envbuf, "%s=%s", name, val); | 2347 sprintf((char *)envbuf, "%s=%s", name, val); |
2348 putenv((char *)envbuf); | 2348 putenv((char *)envbuf); |
2349 } | 2349 } |
3017 char_u * | 3017 char_u * |
3018 concat_fnames(char_u *fname1, char_u *fname2, int sep) | 3018 concat_fnames(char_u *fname1, char_u *fname2, int sep) |
3019 { | 3019 { |
3020 char_u *dest; | 3020 char_u *dest; |
3021 | 3021 |
3022 dest = alloc((unsigned)(STRLEN(fname1) + STRLEN(fname2) + 3)); | 3022 dest = alloc(STRLEN(fname1) + STRLEN(fname2) + 3); |
3023 if (dest != NULL) | 3023 if (dest != NULL) |
3024 { | 3024 { |
3025 STRCPY(dest, fname1); | 3025 STRCPY(dest, fname1); |
3026 if (sep) | 3026 if (sep) |
3027 add_pathsep(dest); | 3027 add_pathsep(dest); |
3038 concat_str(char_u *str1, char_u *str2) | 3038 concat_str(char_u *str1, char_u *str2) |
3039 { | 3039 { |
3040 char_u *dest; | 3040 char_u *dest; |
3041 size_t l = STRLEN(str1); | 3041 size_t l = STRLEN(str1); |
3042 | 3042 |
3043 dest = alloc((unsigned)(l + STRLEN(str2) + 1L)); | 3043 dest = alloc(l + STRLEN(str2) + 1L); |
3044 if (dest != NULL) | 3044 if (dest != NULL) |
3045 { | 3045 { |
3046 STRCPY(dest, str1); | 3046 STRCPY(dest, str1); |
3047 STRCPY(dest + l, str2); | 3047 STRCPY(dest + l, str2); |
3048 } | 3048 } |
3074 char_u *new_fname = NULL; | 3074 char_u *new_fname = NULL; |
3075 | 3075 |
3076 if (fname == NULL) | 3076 if (fname == NULL) |
3077 return NULL; | 3077 return NULL; |
3078 | 3078 |
3079 buf = alloc((unsigned)MAXPATHL); | 3079 buf = alloc(MAXPATHL); |
3080 if (buf != NULL) | 3080 if (buf != NULL) |
3081 { | 3081 { |
3082 if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL) | 3082 if (vim_FullName(fname, buf, MAXPATHL, force) != FAIL) |
3083 new_fname = vim_strsave(buf); | 3083 new_fname = vim_strsave(buf); |
3084 else | 3084 else |
4229 | 4229 |
4230 /* Make room for another item in the file list. */ | 4230 /* Make room for another item in the file list. */ |
4231 if (ga_grow(gap, 1) == FAIL) | 4231 if (ga_grow(gap, 1) == FAIL) |
4232 return; | 4232 return; |
4233 | 4233 |
4234 p = alloc((unsigned)(STRLEN(f) + 1 + isdir)); | 4234 p = alloc(STRLEN(f) + 1 + isdir); |
4235 if (p == NULL) | 4235 if (p == NULL) |
4236 return; | 4236 return; |
4237 | 4237 |
4238 STRCPY(p, f); | 4238 STRCPY(p, f); |
4239 #ifdef BACKSLASH_IN_FILENAME | 4239 #ifdef BACKSLASH_IN_FILENAME |