comparison src/winclip.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 209f65bb155f
children 695d9ef00b03
comparison
equal deleted inserted replaced
16763:fccf84413b53 16764:ef00b6bc186b
167 LPSTR *out, int *outlen, 167 LPSTR *out, int *outlen,
168 LPCSTR def, LPBOOL useddef) 168 LPCSTR def, LPBOOL useddef)
169 { 169 {
170 *outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef); 170 *outlen = WideCharToMultiByte(cp, flags, in, inlen, NULL, 0, def, useddef);
171 /* Add one one byte to avoid a zero-length alloc(). */ 171 /* Add one one byte to avoid a zero-length alloc(). */
172 *out = (LPSTR)alloc((unsigned)*outlen + 1); 172 *out = (LPSTR)alloc(*outlen + 1);
173 if (*out != NULL) 173 if (*out != NULL)
174 { 174 {
175 WideCharToMultiByte(cp, flags, in, inlen, *out, *outlen, def, useddef); 175 WideCharToMultiByte(cp, flags, in, inlen, *out, *outlen, def, useddef);
176 (*out)[*outlen] = 0; 176 (*out)[*outlen] = 0;
177 } 177 }
510 /* Convert the text for CF_TEXT to Active codepage. Otherwise it's 510 /* Convert the text for CF_TEXT to Active codepage. Otherwise it's
511 * p_enc, which has no relation to the Active codepage. */ 511 * p_enc, which has no relation to the Active codepage. */
512 metadata.txtlen = WideCharToMultiByte(GetACP(), 0, out, len, 512 metadata.txtlen = WideCharToMultiByte(GetACP(), 0, out, len,
513 NULL, 0, 0, 0); 513 NULL, 0, 0, 0);
514 vim_free(str); 514 vim_free(str);
515 str = (char_u *)alloc((unsigned)(metadata.txtlen == 0 ? 1 515 str = (char_u *)alloc(metadata.txtlen == 0 ? 1 : metadata.txtlen);
516 : metadata.txtlen));
517 if (str == NULL) 516 if (str == NULL)
518 { 517 {
519 vim_free(out); 518 vim_free(out);
520 return; /* out of memory */ 519 return; /* out of memory */
521 } 520 }
653 return NULL; 652 return NULL;
654 } 653 }
655 convert_setup(&conv, NULL, NULL); 654 convert_setup(&conv, NULL, NULL);
656 655
657 length = utf8_to_utf16(str, *lenp, NULL, NULL); 656 length = utf8_to_utf16(str, *lenp, NULL, NULL);
658 ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR))); 657 ret = (WCHAR *)alloc((length + 1) * sizeof(WCHAR));
659 if (ret != NULL) 658 if (ret != NULL)
660 { 659 {
661 utf8_to_utf16(str, *lenp, (short_u *)ret, NULL); 660 utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
662 ret[length] = 0; 661 ret[length] = 0;
663 } 662 }