Mercurial > vim
comparison src/mbyte.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 | 7ae2396cef62 |
children | ce04ebdf26b8 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
4315 r = (char_u *)"latin1"; | 4315 r = (char_u *)"latin1"; |
4316 return vim_strsave(r); | 4316 return vim_strsave(r); |
4317 } | 4317 } |
4318 | 4318 |
4319 /* copy "enc" to allocated memory, with room for two '-' */ | 4319 /* copy "enc" to allocated memory, with room for two '-' */ |
4320 r = alloc((unsigned)(STRLEN(enc) + 3)); | 4320 r = alloc(STRLEN(enc) + 3); |
4321 if (r != NULL) | 4321 if (r != NULL) |
4322 { | 4322 { |
4323 /* Make it all lower case and replace '_' with '-'. */ | 4323 /* Make it all lower case and replace '_' with '-'. */ |
4324 p = r; | 4324 p = r; |
4325 for (s = enc; *s != NUL; ++s) | 4325 for (s = enc; *s != NUL; ++s) |
4601 if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) | 4601 if (len == 0 || ICONV_ERRNO == ICONV_E2BIG) |
4602 { | 4602 { |
4603 /* Allocate enough room for most conversions. When re-allocating | 4603 /* Allocate enough room for most conversions. When re-allocating |
4604 * increase the buffer size. */ | 4604 * increase the buffer size. */ |
4605 len = len + fromlen * 2 + 40; | 4605 len = len + fromlen * 2 + 40; |
4606 p = alloc((unsigned)len); | 4606 p = alloc(len); |
4607 if (p != NULL && done > 0) | 4607 if (p != NULL && done > 0) |
4608 mch_memmove(p, result, done); | 4608 mch_memmove(p, result, done); |
4609 vim_free(result); | 4609 vim_free(result); |
4610 result = p; | 4610 result = p; |
4611 if (result == NULL) /* out of memory */ | 4611 if (result == NULL) /* out of memory */ |